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 #37

Closed
Oublier opened this issue Dec 7, 2010 · 1 comment
Closed

breadcrumbs and CRUD #37

Oublier opened this issue Dec 7, 2010 · 1 comment

Comments

@Oublier
Copy link

Oublier commented Dec 7, 2010

First off; great gem!

I'm relatively new to Rails and Ruby so please forgive my ignorance. I'm using simple-navigation to render breadcrumbs. I having trouble specifically with crumbing for CRUD; specifically with SHOW and EDIT. I cant seem to get the path helpers to recognize the record ID for the notifications table.

Render line in app/views/layouts/application.html.erb


<%= render_navigation :renderer => :breadcrumbs, :join_with => " > " %>

navigation.rb:


SimpleNavigation::Configuration.run do |navigation|

navigation.items do |primary|

primary.item :home, 'Home', '/' do |home|
  home.item :notification, 'Portal Notifications', notifications_path do |notify|
    notify.item :notification, 'New Notification', new_notification_path
    notify.item :notification, 'Show Notification', notification_path(id)
    notify.item :notification, 'Edit Notification', edit_notification_path(id)
  end
end

end
end

Error:


undefined local variable or method `id'

Thanks for any help!

@andi
Copy link
Collaborator

andi commented Dec 7, 2010

two things:

  1. you have to pass a resource/object to the show and edit url_helpers which you usually load in the controllers. e.g. notification_path(@notification) or edit_notification_path(@notification) --> id is not defined in your case...

  2. You should guard your show and edit items agains nil-objects, i.e. the items should not be evaluated if @notification is nil or not set, e.g.

notify.item :notification, 'Show Notification', lambda {notification_path(@notification)}, :unless => lambda {@notification.nil?} 

Hope that makes sense, let me know if not...
Andi

This issue was closed.
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