如何在Devise的注册页面中添加其他字段? [英] How do I add additional fields to the Devise 'sign up' page?

查看:98
本文介绍了如何在Devise的注册页面中添加其他字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经安装了设备,一切正常,但我想添加我的注册页面还有几个字段。例如,我有一个我想添加的用户类型下拉(由用户类型模型填充 - 在测试中工作正常),并且还要根据用户的类型(CC信息等)收集不同的信息。有人可以指出我的资源或某事。我试图覆盖注册控制器,但并没有链接到设计视图或符合DRY原则对我(以复制视图)。感谢您提出建议。

解决方案

只需向用户添加列,然后在视图中添加其他功能。

 脚本/生成迁移add_user_type_to_user 

然后在您的迁移耙式文件中:

  add_column:users,:user_type,:string 

然后 rake db:migrate 。接下来,您可以添加一个下拉列表到您的视图,您可以通过 rails来生成设计:视图

 <%= f.select:user,:user_type options_for_select(['admin','no status'])%> 


I'm very new to Rails and devise so here goes...

I've installed devise and everything is working fine but I'd like to add a few more fields to my registration page. For instance, I have a usertype drop down that I'd like to add (populated by a Usertype Model - works fine in test) and would also like to collect different information depending on the type of user it is (CC information, etc.) Can someone point me to a resource or something. I tried overriding the Registration controller but that didn't link back to the devise views or fall in line with DRY principles to me (to copy the views). Thanks in advance for suggestions.

解决方案

Just add columns to the user and then add additional features in the views.

script/generate migration add_user_type_to_user

Then in your migration rake file:

add_column :users, :user_type, :string

and then rake db:migrate. Next you can add a drop down to your view and you can get those through rails generate devise:views:

<%= f.select :user, :user_type options_for_select(['admin', 'no status'])%>

这篇关于如何在Devise的注册页面中添加其他字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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