Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ApplicationHelper
- # Generate breadcrumb links for a resourceful route
- # for example the path "/customers/2/property/5/expenditures/27" becomes links to:
- # <All Customers> <This Customer> <All Properties> <This Property> <All Expenditures>
- def breadcrumbs path = request.path
- o = p = ''
- path.split(/\//)[1..-2].map do |e|
- p += '/'+e # Build the path for each link
- case e
- when /^[0-9]*$/
- link_to "This #{o.singularize.titleize}", p
- else
- o = e
- link_to "All #{e.titleize}", p
- end
- end*"\n"
- end
- end
Add Comment
Please, Sign In to add comment