设计两种型号 [英] devise for two models

查看:148
本文介绍了设计两种型号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用嵌套身份验证构建一个应用程序,这意味着我有一个House模块(设计),一个房子有很多用户,一次在House认证中,我希望用户能够以好。我还添加了一个Devise的用户模型。我的问题是,现在我收到错误,因为我为房屋设计的设计sign_up表单不适用于用户模型。如何为具有设计的两个不同用户模型创建单独的sign_up和sign_in表单?还是有更好的方法去做这个?谢谢!

解决方案


如何为具有设计的两个不同用户模型创建单独的sign_up和sign_in表单?




  rails g devise:views 
pre>

这将创建一个app / views / devise。



然后:setconfig.scoped_views = true insideconfig / initializers / devise.rb。



从README:


执行此操作后,您将可以根据角色users / sessions / new和admins / sessions / new等角色进行查看。如果在范围内没有找到视图,Devise将使用默认视图在devise / sessions / new。



I am building an app with "nested authentication" That means that I have a House modle (with devise) and a house has many users and once inside the House authentication, I would like the users to be able to sign in as well. I have also added a User model with Devise. My question is that right now I am getting errors because I the devise sign_up form that I have designed for Houses doesn't work for the User model. How do I create separate sign_up and sign_in forms for two different user models with devise? Or is there a better way to go about doing this? Thanks!

解决方案

How do I create separate sign_up and sign_in forms for two different user models with devise?

rails g devise:views

This will create an app/views/devise.

Then: set "config.scoped_views = true" inside "config/initializers/devise.rb".

From the README:

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".

这篇关于设计两种型号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆