[英]Rails: Devise: How can I edit user information?
I have a Rails app set up using Devise, with a Registration controller. 我有一个使用Devise设置的Rails应用程序,带有注册控制器。
What's working so far: 到目前为止有什么工作:
New user registration Login Logout Home About Confirmation Password reset 新用户注册登录注销主页关于确认密码重置
Not working is edit, as in I can't figure out the URL/REST call I should be making to get edit to show up. 不工作是编辑,因为我无法弄清楚我应该进行的URL / REST调用以显示编辑。 I do have a views/registrations/edit.html.erb page. 我有一个views / registrations / edit.html.erb页面。
Following is the portion of my routes that's specific to Registration: 以下是我的路线中特定于注册的部分:
cancel_user_registration GET /cancel(.:format) registrations#cancel
user_registration POST / registrations#create
new_user_registration GET /request_invite(.:format) registrations#new
edit_user_registration GET /edit(.:format) registrations#edit
Following is the portion of my routes.rb that's specific to devise: 以下是我的routes.rb中特定于设计的部分:
devise_for :users, :controllers => { :registrations => 'registrations', :confirmations => 'confirmations' }, :path => '', :path_names => { :sign_in => "login", :sign_up => "request_invite" }
I tried the following: 我尝试了以下方法:
http://localhost:3000/edit
http://localhost:3000/edit/:id
http://localhost:3000/registrations/:id/edit
http://localhost:3000/user/:id/edit
I get: No route matches [GET] ... 我明白了:没有路线匹配[GET] ......
There are a couple of useful Q&A sessions on StackOverfloww, but I could not figure out how to make the advice here work for me. StackOverfloww上有几个有用的问答环节,但我无法弄清楚如何在这里为我提供建议。 Any ideas? 有任何想法吗?
I typically just add a 我通常只是添加一个
resources :users, only: [:show, :edit, :update]
This will give you a /users/:id route (your profile), and can edit and update it. 这将为您提供/ users /:id路由(您的配置文件),并可以编辑和更新它。 That way, you're interacting with the User model just as you normally would, outside of Devise. 这样,您就像平常一样在Devise之外与User模型进行交互。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.