Guest User

Untitled

a guest
Jun 22nd, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. module ApplicationHelper
  2. # Generate breadcrumb links for a resourceful route
  3. # for example the path "/customers/2/property/5/expenditures/27" becomes links to:
  4. # <All Customers> <This Customer> <All Properties> <This Property> <All Expenditures>
  5. def breadcrumbs path = request.path
  6. o = p = ''
  7. path.split(/\//)[1..-2].map do |e|
  8. p += '/'+e # Build the path for each link
  9. case e
  10. when /^[0-9]*$/
  11. link_to "This #{o.singularize.titleize}", p
  12. else
  13. o = e
  14. link_to "All #{e.titleize}", p
  15. end
  16. end*"\n"
  17. end
  18. end
Add Comment
Please, Sign In to add comment