Skip to content

Instantly share code, notes, and snippets.

@RelativeMedia
Created October 3, 2012 15:08
Show Gist options
  • Select an option

  • Save RelativeMedia/3827451 to your computer and use it in GitHub Desktop.

Select an option

Save RelativeMedia/3827451 to your computer and use it in GitHub Desktop.
def nav_link(link_text, controller, action = nil)
active = params[:controller] == controller.to_s &&
(action.nil? || params[:action] == action.to_s)
class_name = active ? "active" : nil
content_tag(:li, :class => class_name) do
link_to link_text, controller
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment