Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Last active December 12, 2015 03:29
Show Gist options
  • Save alvinsj/4707650 to your computer and use it in GitHub Desktop.
Save alvinsj/4707650 to your computer and use it in GitHub Desktop.
simple breadcrumb in rails
<ul class="breadcrumb" id="breadcrumb" >
<li>
<%= breadcrumbs.join("<span class='divider'>/</span></li><li>").html_safe %>
</li>
</ul>
def show
add_to_breadcrumb @admin_app.name, admin_app_path(@admin_app)
end
def self.add_to_breadcrumb(title, link=nil)
before_filter do |instance|
instance.add_to_breadcrumb(title, link)
end
end
add_to_breadcrumb "Home", "/"
def add_to_breadcrumb(title, link=nil)
@breadcrumbs ||= []
item = (link.nil? ? title : "<a href='#{link}'>#{title}</a>")
@breadcrumbs << item unless @breadcrumbs.include?(item)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment