Skip to content

@unders /application.html.erb forked from henrik/application.html.erb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
You are here:
<%= trail.to_html(response) %>
class ApplicationController < ActionController::Base
before_filter :trail
def self.trail(&block)
# Controller-level trails become filters so they run inside the
# request/response cycle, where internationalization etc works.
before_filter {|controller| block.call(controller.send(:trail)) }
end
trail {|t| t << ['Home', '/'] }
protected
def trail
@breadcrumb_trail ||= BreadcrumbTrail.new
end
helper_method :trail
class BreadcrumbTrail
def initialize
@crumbs = []
end
def <<(crumb)
@crumbs << crumb
end
def append(crumbs)
@crumbs += crumbs
end
def to_html(response)
template = response.template
@crumbs.map {|text, url| template.instance_eval {
link_to_unless_current(h(text), url)
} }.join(" &gt; ")
end
end
end
class ItemsController < ApplicationController
trail {|t| t << ['Items', '/items'] }
def show
trail << ['Specific item from controller', '/items/123']
end
end
<%
trail << ['Specific item from view', '/items/123']
# Note that since layouts are rendered after their child template,
# trails appended in a layout will currently come after those
# appended in the child templates.
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.