Skip to content

Instantly share code, notes, and snippets.

@atomical
Last active Dec 19, 2015
Embed
What would you like to do?
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