Skip to content

Instantly share code, notes, and snippets.

@yamaaki
Created September 21, 2015 18:35
Show Gist options
  • Save yamaaki/1fb1dca51d50f83d0fdb to your computer and use it in GitHub Desktop.
Save yamaaki/1fb1dca51d50f83d0fdb to your computer and use it in GitHub Desktop.
module ApplicationHelper
ACTIVE = {
new_member_session: [ { 'member/members/sessions' => %w(new create ) } ],
edit_member_registration: [ { 'member/members/registrations' => %w(edit update destroy) } ],
destroy_member_session: [ { 'member/members/sessions' => %w(destroy ) } ],
new_admin_session: [ { 'admin/admins/sessions' => %w(new create ) } ],
destroy_admin_session: [ { 'admin/admins/sessions' => %w(destroy ) } ],
}
def hl(key)
actives = ACTIVE[key] || []
controllers = []
actions = []
actives.each do |item|
item.each do |controller, actions|
actions.each do |action|
list = action.split('?')
acname = list[0]
param = list[1]
if param
list2 = param.split('=')
param_key = list2[0]
param_val = list2[1]
end
if controller_path == controller.to_s && acname == action_name
if param_key
if param_val == params[param_key]
return lambda { true }
end
else
return lambda { true }
end
end
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