Created
November 22, 2012 10:42
-
-
Save akirill0v/4130506 to your computer and use it in GitHub Desktop.
Модуль? который инклудится в нужный нам класс, например ApplicationController.rb
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 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 |
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
| = link_to 'title', 'edit_user_path' if can?('edit_user') |
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
| 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