Created
August 12, 2015 13:59
-
-
Save yamaaki/dfd9f40f1850f85af9e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module ApplicationHelper | |
ACTIVE = { | |
welcome: [ { welcome: %w(index ) } ], | |
new_book: [ { books: %w(new create ) } ], | |
books: [ { books: %w(index edit show update destroy) }, ], | |
} | |
def hl(key) | |
actives = ACTIVE[key] || [] | |
controllers = [] | |
actions = [] | |
actives.each do |item| | |
item.each do |controller, actions| | |
if controller_name == controller.to_s && actions.include?(action_name) | |
return lambda { true } | |
end | |
end | |
end | |
return lambda { false } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment