设计两种型号 [英] devise for two models
问题描述
如何为具有设计的两个不同用户模型创建单独的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屋!