Return to Snippet

Revision: 16324
at July 30, 2009 23:19 by obsessivejosh


Initial Code
#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')%>

Initial URL
http://snippets.dzone.com/posts/show/2016

Initial Description
note to self

Initial Title
Highlight Section Navigation

Initial Tags

                                

Initial Language
Rails