module BackStack::Helpers
These functions will be available in views
Public Instance Methods
backstack_link(text, *args)
click to toggle source
# File lib/backstack.rb, line 73 def backstack_link(text, *args) bs_graph = controller.class.get_bs_graph # found it! lol # If we don't have these we can't do anything return unless session[:bs_stack] && bs_graph # If the top of stack (current location) is stacked on top of # link the graph indicates it closes to, then create a link from # that. current = session[:bs_stack][-1] previous = session[:bs_stack][-2] if current && previous && bs_graph[current.first].include?(previous.first) return link_to(text, previous.second, *args) end end
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