Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breadcrumbs and CRUD: No route matches {:action=>"show", :controller=>"...", :id=>nil}, missing required keys: [:id] #220

Open
nevrome opened this issue Jul 23, 2019 · 1 comment

Comments

@nevrome
Copy link

nevrome commented Jul 23, 2019

A great gem! Unfortunately I have issues getting it to work properly for CRUD routes. Maybe you can point me to a solution.

I followed the advice in #37 to define the navigation structure. For example:

#config/navigation.rb
data.item :arch_objects, 'arch_objects', arch_objects_path do |i|
  i.item :arch_object, 'new arch_object', new_arch_object_path
  i.item :arch_object, 'show arch_object', lambda {arch_object_path(@arch_object)}, :unless => lambda {@arch_object.nil?}
  i.item :arch_object, 'edit arch_object', lambda {edit_arch_object_path(@arch_object)}, :unless => lambda {@arch_object.nil?}
end

Unfortunately with this setting everything works fine only for the edit and the show action. For the new action I get the following error:

No route matches {:action=>"show", :controller=>"arch_objects", :id=>nil}, missing required keys: [:id]

If I turn off the navigation for the edit and the show action, the new action view is displayed normally and the breadcrumb menu works.

#config/navigation.rb
data.item :arch_objects, 'arch_objects', arch_objects_path do |i|
  i.item :arch_object, 'new arch_object', new_arch_object_path
 # i.item :arch_object, 'show arch_object', lambda {arch_object_path(@arch_object)}, :unless => lambda {@arch_object.nil?}
 # i.item :arch_object, 'edit arch_object', lambda {edit_arch_object_path(@arch_object)}, :unless => lambda {@arch_object.nil?}
end

What's the reason for this strange behaviour? How is the new action related to the show action with simple-navigation activated?

@andi
Copy link
Collaborator

andi commented Jul 29, 2019

Could you put together a repo with that setup to make it easier to track this down?

@nevrome nevrome mentioned this issue Aug 27, 2019
58 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants