/ Published in: Rails
note to self
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#put in application_helper.rb : def section_link(name,options) if options[:action] == @current_action and options[:controller] == @current_controller link_to(name, options, :class => 'on') else link_to(name,options) end end #initialize vars in controller before_filter :instantiate_controller_and_action_names def instantiate_controller_and_action_names @current_action = action_name @current_controller = controller_name end #usage in view: <%=section_link('Home',:controller => 'articles', :action => 'index')%>
URL: http://snippets.dzone.com/posts/show/2016