I have Devise gem for user authentication. Basically, I want to override registrations_controller.rb in Devise gem locally. The code in gem:
class Devise::RegistrationsController < DeviseController
...
def update
...(need to override)
end
end
I want to redirect user to other page if particular attribute in edit_form is selected.
I would advise against overriding that method. Instead, take a look at the Wiki page about custom redirects after a profile edit. It explains to override this method:
def after_update_path_for(resource)
user_path(resource)
end
You could return different paths based on your attribute, so for example
def after_update_path_for(resource)
resource.foo? ? foo_path : bar_path
end
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.