module BackStack::Helpers

These functions will be available in views

Public Instance Methods

backstack_trail() { |call| ... } click to toggle source

Iterator to build breadcrumb trails

# File lib/backstack.rb, line 93
def backstack_trail

  hashify = lambda{|x|
    c, a = x[0].split /#/
    label = x[2] || "#{a.capitalize}" # if forgot
    {:controller => c, :action => a, :fullpath => x[1], :label => label}
  }

  if block_given?
    session[:bs_stack].each { |x| yield hashify.call(x) }
  else # return an array
    session[:bs_stack].map { |x| hashify.call(x) }        
  end

end