Skip to content

Instantly share code, notes, and snippets.

@mokevnin
Created February 1, 2012 08:48
Show Gist options
  • Save mokevnin/1716007 to your computer and use it in GitHub Desktop.
Save mokevnin/1716007 to your computer and use it in GitHub Desktop.
module AccessHelper
include AuthHelper
def check_access(values = {})
acl.check! self.class.to_s, self.action_name, current_roles, values
end
def current_roles
@current_roles ||= current_user.roles_hash.keys
end
def acl
YaAcl::Acl.instance
end
def can?(route_method, action = nil, options = {})
url_options = send "hash_for_#{route_method}_path"
resource = "#{url_options[:controller].to_s.camelize}Controller"
privilege = action || url_options[:action]
acl.allow? resource, privilege, current_roles, options
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment