如何简单快速的完成用户角色管理和权限控制(3)安装 devise, rolify, cancan
- UID
- 1066743
|
如何简单快速的完成用户角色管理和权限控制(3)安装 devise, rolify, cancan
安装 devise, rolify, cancan- 编辑程序的 Gemfile,添加 devise,rolify,cancan 的 gem 包
清单3. Gemfile 中引入相关 gem 包gem 'devise'
gem 'rolify'
gem 'cancan'
$bundle install
- 运行 devise generate 来完成 devise 的安装
$ rails generate devise:install
清单4. 运行 devise generateshirleydembpeveloperWork shirley$ rails generate devise:install
Running via Spring preloader in process 60215
1
| create config/initializers/devise.rb
|
create config/locales/devise.en.yml
1
| ==========================================================================
|
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root to: "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
4. You can copy Devise views (for customization) to your app by running:
rails g devise:views
需要针对你的项目,根据提示来进行相应的配置。如果你想要自定义 devise 的页面,需要先生成页面文件,然后进行重写,关于 devise 的定制化在本文的如何定制 devise 章节会介绍。 |
|
|
|
|
|