Skip to content

Instantly share code, notes, and snippets.

@indirect
Created June 20, 2010 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save indirect/445652 to your computer and use it in GitHub Desktop.
Save indirect/445652 to your computer and use it in GitHub Desktop.
resource-aware breadcrumbs
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
@nishandan
Copy link

can you explain how to integrate this with application? i mean in the html pages.

@indirect
Copy link
Author

Sorry, I have no idea what you're asking.

@Shashien
Copy link

Shashien commented Dec 7, 2010

In wich rb file do you have to put this piece of code? in the application_helper or in something else? And is this all the code you need to create a breadcrumb? Nothing in the view like render breadcrumb?

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