Playing with link_to helper

Hi *, someone has suggestions on how to improve this code ? For example I'd like my parameteres to be similar to the original link_to helper, :controller => :blah, :action => :blah and so on ...

   def link_to_current_class(name, controller, action)      link_to name, :controller => controller, :action => action if params[:controller] != controller      link_to name, { :controller => controller, :action => action }, { :class => 'current' }    end

A better naming is also appreciated :slight_smile:


I think something like this should work

def clever_name_for_link_helper(text, controller, action) options = (if params[:controller] == controller) ? {:class => :current} : {} link_to text, {:controller => controller, :action => action}, options


I had a hard time with the name [obviously the one I used isn’t real] because link_to_current_class implies you’re linking to the current_class. Perhaps link_with_current_class or mark_link_if_current_class or something?