How do I use the Ruby on Rails devise gem to stay on the Edit User page after I edit my information?
I figured out how to do it.
First, create a RegistrationsController in the CLI by typing
rails g controller Registrations
Then, create a new folder called my_devise in your app/controllers folder, and move the newly generated RegistrationsController into that folder.
Next, open up RegistrationsController, and change the contents to
class MyDevise::RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
user_path(resource)
end
end
Now, move the app/views/devise/registrations folder to a new folder called app/views/my_devise/registrations, but leave the sessions and shared folders in the devise folder.
Then, in the config/routes.rb file, change the line devise_for :users to devise_for :users, :controllers => {:registrations => "my_devise/registrations"}.
And that's it! I think I covered it all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With