简体   繁体   中英

Rails: Devise: How can I edit user information?

I have a Rails app set up using Devise, with a Registration controller.

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. I do have a views/registrations/edit.html.erb page.

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:

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] ...

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. 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. That way, you're interacting with the User model just as you normally would, outside of Devise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM