Skip to content

Instantly share code, notes, and snippets.

@atomical
Last active December 19, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomical/5901432 to your computer and use it in GitHub Desktop.
Save atomical/5901432 to your computer and use it in GitHub Desktop.
def active_for_controller controller_name
params[:controller].to_s == controller_name.to_s ? 'active' : ''
end
def active_for_action action_name
params[:action].to_s == action_name.to_s ? 'active' : ''
end
Usage:
= link_to 'Some resource', resource_path, class: active_for_controller('resource')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment