RubyOnRails Breadcrumb Helper

I needed a stupid simple breadcrumb helper that was fast and didn’t require crazy configuration. I don’t need a high level of control, so I figured, lets just take the requested path and link the segments, and here we have it.

1
2
3
4
5
6
7
8
def breadcrumbs(separator = ' > ', options = {})
  (crumbs, previous) = [], []
  request.path.split('/').each do |part|
    previous << part
    crumbs << link_to(part, previous.join('/'), options)
  end
  crumbs.join(separator)
end

Feel free to leave feedback.

Related Posts

  1. Affiliate Click Tracking With Rack And Redis Because I Care
  2. Not Using IPAddr Should Result In You Being Mauled By A Bear
Programming, RubyOnRails

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

blog comments powered by Disqus