Skip to content

Instantly share code, notes, and snippets.

@akirill0v
Created November 22, 2012 10:42
Show Gist options
  • Save akirill0v/4130506 to your computer and use it in GitHub Desktop.
Save akirill0v/4130506 to your computer and use it in GitHub Desktop.
Модуль? который инклудится в нужный нам класс, например ApplicationController.rb
module AccessHelper
# ...
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
= link_to 'title', 'edit_user_path' if can?('edit_user')
YaAcl::Builder.build do
roles do
role :site_admin
end
resources :site_admin do
resource 'Web::UsersController' do
privilege :index
privilege :show
privilege :edit
# ...
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment