Created
July 4, 2017 10:11
-
-
Save lalitlogical/8cb6dca6fe250e61887c8cbf78090e3d to your computer and use it in GitHub Desktop.
Active proper menu in Rails views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def active controllers, action_names = nil | |
class_name = controllers.split(",").any? { |c| controller.controller_name == c.strip } ? "active" : "" | |
if class_name.present? && action_names.present? | |
return action_names.split(",").any? { |an| controller.action_name == an.strip } ? "active" : "" | |
end | |
class_name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment