Skip to content

Instantly share code, notes, and snippets.

@martinrehfeld
Forked from indirect/application_helper.rb
Created June 20, 2010 17:54
Show Gist options
  • Save martinrehfeld/445975 to your computer and use it in GitHub Desktop.
Save martinrehfeld/445975 to your computer and use it in GitHub Desktop.
Breadcrumbs helper -- requires inherited_resources gem
class ApplicationHelper
def breadcrumbs
result = "".html_safe
association_chain.each_with_index do |item, index|
# note that .name works for both classes and objects
result << link_to(item.name.humanize.titlecase, association_chain[0..index])
result << " &raquo; ".html_safe
end
result << resource.name.humanize.titleize
end
end
@kelso
Copy link

kelso commented Dec 4, 2012

Thank you! I'm building breadcrumbs upon this code! I did't know method association_chain. Awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment