Sha256: f00a5db145644fcd63311c51fcd1d395f862e1096906e34d2a983442209d33fa
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
## TheRole Gem for providing simple, but powerful and flexible role system for ROR3 applications. Based on Hashes. * Based on MVC semantik (easy to understand what's happening) * Realtime dynamically management with simple interface * Customizable ## Installation Gemfile ``` ruby gem 'the_role' ``` ``` ruby bundle install ``` ``` ruby rake the_role_engine:install:migrations >> Copied migration 20111028145956_create_roles.rb from the_role_engine rails g model user role_id:integer rails g model role --migration=false rake db:create && rake db:migrate ``` Creating roles for test ``` ruby rake db:roles:test >> Administrator, Moderator of pages, User, Demo ``` ## Manage roles ``` ruby rails s ``` **admin_roles_path** => **http://localhost:3000/admin/roles** ## How it works ``` ruby rails c user = User.first user.role = Role.where(:name => :demo).first user.save user.admin? => false user.moderator? :pages => false user.has_role? :pages, :index => true user.role = Role.where(:name => :moderator).first user.save user.admin? => false user.moderator? :pages => true user.has_role? :pages, :any_crazy_name => true user.role = Role.where(:name => :admin).first user.save user.admin? => true user.moderator? :pages => true user.moderator? :any_crazy_name => true user.has_role? :any_crazy_name, :any_crazy_name => true ``` ## Extend TheRole's controllers with **login_require** method **config/initialisers/the_role.rb** ``` ruby require 'authenticated_system' Admin::RolesController.send :include, AuthenticatedSystem Admin::RoleSectionController.send :include, AuthenticatedSystem Admin::RolesController.send :before_filter, :login_require Admin::RoleSectionController.send :before_filter, :login_require ``` Copyright (c) 2011 [Ilya N. Zykin Github.com/the-teacher], released under the MIT license
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
the_role-1.2.1 | README.md |
the_role-1.2.0 | README.md |