I have a Rails 3 App using devise. I want to create a User/Profile edit page. Where a user can edit the name, add/change their photo etc...
我有一个使用设计的Rails 3应用程序。我想创建一个用户/个人资料编辑页面。用户可以编辑名称,添加/更改他们的照片等...
I'd like to do this in the right rails/devise way. What's the way of handling this? I see a app/views/devise/registrations/edit.html.erb file
我想以正确的轨道/设计方式做到这一点。处理这个问题的方法是什么?我看到了app / views / devise / registrations / edit.html.erb文件
Do I edit that file?
我可以编辑该文件吗?
Or do I create a app/views/users/edit.html.erb and customize that experience? But then what do you do regarding the controller? Create a new controller?
或者我是否创建app / views / users / edit.html.erb并自定义该体验?但那你对控制器做了什么呢?创建一个新的控制器?
Thanks
2 个解决方案
#1
13
You may edit the devise/registrations/edit.html.{erb,haml}
file and customize it to your needs, maybe even add any additional fields that may be in your user model but not on the form.
您可以编辑设计/注册/ edit.html。{erb,haml}文件并根据需要对其进行自定义,甚至可以添加可能在您的用户模型中但不在表单上的任何其他字段。
I believe it's also possible to have a common CRUD interface for users along with the Devise's, but then you'd have to create a new controller and add the views and everything, so it is easier and preferable to simply override Devise's views to change or add what you need.
我相信也可以为用户和Devise提供一个通用的CRUD界面,但是你必须创建一个新的控制器并添加视图和所有内容,因此简单地覆盖Devise的视图来更改或者更容易添加你需要的东西。
You can generate them with rails g devise:views
.
您可以使用rails g devise:views生成它们。
#2
0
You could also create a user profile edit page directly from a controller of your choice in the app that modifies your user model appropriately.
您还可以直接从应用程序中选择的控制器创建用户配置文件编辑页面,以适当地修改用户模型。
#1
13
You may edit the devise/registrations/edit.html.{erb,haml}
file and customize it to your needs, maybe even add any additional fields that may be in your user model but not on the form.
您可以编辑设计/注册/ edit.html。{erb,haml}文件并根据需要对其进行自定义,甚至可以添加可能在您的用户模型中但不在表单上的任何其他字段。
I believe it's also possible to have a common CRUD interface for users along with the Devise's, but then you'd have to create a new controller and add the views and everything, so it is easier and preferable to simply override Devise's views to change or add what you need.
我相信也可以为用户和Devise提供一个通用的CRUD界面,但是你必须创建一个新的控制器并添加视图和所有内容,因此简单地覆盖Devise的视图来更改或者更容易添加你需要的东西。
You can generate them with rails g devise:views
.
您可以使用rails g devise:views生成它们。
#2
0
You could also create a user profile edit page directly from a controller of your choice in the app that modifies your user model appropriately.
您还可以直接从应用程序中选择的控制器创建用户配置文件编辑页面,以适当地修改用户模型。