Ruby on Rails 用户角色管理
2007年4月11日星期三
使用acts_as_authenticated + authorization plugin 实现 Ruby on Rails 用户角色管理,step-by-step :
$ mysqladmin create auth_development
$ rails auth
$ ./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated
$ ./script/plugin install http://svn.writertopia.com/svn/plugins/authorization
$ ./script/generate authenticated user account
$ ./script/generate role_model role
$ rake db:migrate
added following to my environment.rb:
AUTHORIZATION_MIXIN = “object roles”
DEFAULT_REDIRECTION_HASH = { :controller => ‘account’, :action =>
‘login’ }
added those to my user model:
acts_as_authorized_user
acts_as_authorizable
and this to test controller:
class TestController < ApplicationController
permit "site_admin or moderator"
def index
render :text => “okok”
end
end
$ ./script/server
标签: Technologies
发表评论
订阅 博文评论 [Atom]
<< 主页