I've been searching high and low for docs on how to edit the registration path after a failed registration.
I have my signup form on my site index page. On failed registration it redirects to the new_user_registration_path not root where the user was. How do I update this?
I've been able to achieve this for the sign-up form by using the customfailure app
class CustomFailure < Devise::FailureApp
def redirect_url
if warden_options[:scope] == :user
new_user_registration_path
else
new_user_registration_path
end
end
def respond
if http_auth?
http_auth
else
redirect
end
end
def redirect
store_location!
flash[:alert] = i18n_message unless flash[:notice]
redirect_to '/'
end
end
Surely a similar option is possible, that doesn't require overriding the devise registrations controller?
You can copy the devise registrations controller from here
You should be able to add something like this:
if resource.save
#handle this
else
#handle this
redirect_to new_user_registration_path
end
Then in your routes:
devise_for :users, :controllers => {:registrations => 'registrations'}
I'm not sure how to do this without overriding the controller
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.