加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何使用Devise处理不同的用户类型

发布时间:2020-12-17 03:26:51 所属栏目:百科 来源:网络整理
导读:我有2种类型的用户.公司和工人. 如何在我只有1个用户的设备中进行管理? 我想为公司和工人创建2个注册页面,但我只想要1个存储用户信息的表格. 解决方法 我会评论codevoice的充分响应,但我还没有足够的代表. 从codevoice链接到的文档: If you have more than
我有2种类型的用户.公司和工人.

如何在我只有1个用户的设备中进行管理?

我想为公司和工人创建2个注册页面,但我只想要1个存储用户信息的表格.

解决方法

我会评论codevoice的充分响应,但我还没有足够的代表.

从codevoice链接到的文档:

If you have more than one role in your
application (such as “User” and
“Admin”),you will notice that Devise
uses the same views for all roles.
Fortunately,Devise offers an easy way
to customize views. All you need to do
is set “config.scoped_views = true”
inside
“config/initializers/devise.rb”.

After doing so,you will be able to
have views based on the role like
“users/sessions/new” and
“admins/sessions/new”. If no view is
found within the scope,Devise will
use the default view at
“devise/sessions/new”. You can also
use the generator to generate scoped
views:

因此,可以为所有设计模型提供一组视图,只需将它们放入设计/会话/ *即可.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读