Board logo

标题: 如何简单快速的完成用户角色管理和权限控制(3)安装 devise, rolify, cancan [打印本页]

作者: look_w    时间: 2018-11-21 20:25     标题: 如何简单快速的完成用户角色管理和权限控制(3)安装 devise, rolify, cancan

安装 devise,                rolify, cancan清单3.                Gemfile 中引入相关 gem 包gem 'devise'
gem 'rolify'
gem 'cancan'
$bundle install
$ 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 章节会介绍。




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0