Skip to content

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

Open
@nevrome

Description

@nevrome

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions