`

rubyonrails Restful Authentication 插件

阅读更多
restful_authentication是Rails的一个认证插件,基于REST方式。它不仅支持最基本的用户管理和认证功能外,还有一个可选的邮件激活功能。

1.安装:rubyscript/plugininstallhttp://svn.techno-weenie.net/projects/plugins/restful_authentication/

2.生成框架代码:ruby script/generate authenticated user sessions --include-activation
这将会生成一个model,以及两个controller:

    models/user.rb,保存用户的登录信息
    controllers/users_controller.rb,提供简单的用户管理功能
    controllers/sessions_controller.rb,提供用户认证支持

–include-activation参数决定是否生成向新注册用户发送激活码的代码。

3. add the resource routes in config/routes.rb.
map.resources :users
map.resource :sessions

If you're on rails 1.2.3 you may need to specify the controller name for the session singular resource:
map.resource :session, :controller => 'sessions'
Also, add an observer to config/environment.rb if you chose the --include-activation option
config.active_record.observers = :user_observer # or whatever you named your model

4.rake db:migrate 然后运行你的程序
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics