如何使用 Devise on MongoDB 添加自定义字段?
我正在尝试使用 mongoid 自定义 Devise on Rails。我已经安装了设备,注册和登录页面已经显示。然而,这些字段只是电子邮件、密码和密码确认。我想添加用户名等字段。我已阅读说明,但它们都使用活动记录。有谁知道在 Mongodb 中执行此操作的简单方法?我是否需要生成设计视图才能在注册表单上添加用户名字段?任何帮助或建议将不胜感激。预先非常感谢!
I'm trying to customize Devise on Rails using mongoid. I have setup devise and sign up and sign in pages are already showing. However, the fields are just email, password and password confirmation. I want to add fields such as username and others. I've read instructions but they're all using active record. Does anyone know a simple way of doing this in Mongodb? Do I need to generate devise views just to add the username field on my sign up form? Any help or suggestions would be appreciated. Thanks a lot in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,你是对的,使用
railsgenerate devise:views
生成设计视图并根据自己的需要自定义它。Yes, you are right, generate devise views with
rails generate devise:views
and customize it for your own needs.并将您需要的密钥添加到您的模型中并使其可访问;
and add the keys you require to your model and make it accessible;