Skip to content

Instantly share code, notes, and snippets.

@yamaaki
Created August 12, 2015 13:59
Show Gist options
  • Save yamaaki/dfd9f40f1850f85af9e6 to your computer and use it in GitHub Desktop.
Save yamaaki/dfd9f40f1850f85af9e6 to your computer and use it in GitHub Desktop.
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