Skip to content

Instantly share code, notes, and snippets.

@mikebaldry
Created October 3, 2012 15:13
Show Gist options
  • Select an option

  • Save mikebaldry/3827486 to your computer and use it in GitHub Desktop.

Select an option

Save mikebaldry/3827486 to your computer and use it in GitHub Desktop.
def active_class(controller, action = nil)
active = params[:controller] == controller.to_s &&
(action.nil? || params[:action] == action.to_s)
active ? "active" : nil
end
def nav_link(link_text, controller)
content_tag(:li, :class => active_class(controller, action) 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