Last active
December 12, 2015 03:29
-
-
Save alvinsj/4707650 to your computer and use it in GitHub Desktop.
simple breadcrumb in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show | |
add_to_breadcrumb @admin_app.name, admin_app_path(@admin_app) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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