Set up redirection after errors

When registering and viewing passwords in Devise, if you receive an error message, it redirects you to the parent page.

So, on the registration page ( /users/sign_up ), if you get an error message, it redirects you / users and shows an error.

On the forgotten password page ( /users/password/new ), if you receive an error message, it redirects you to /users/password and displays an error.

How can I change it so that it does the same as the icon page, if there is an error, it stays on the same page and shows the error.

I looked through Devise and cannot find where the redirect is.

Here are my routes for Devise:

 devise_for :users, :skip => [:sessions] as :user do get 'signin' => 'devise/sessions#new', :as => :new_user_session post 'signin' => 'devise/sessions#create', :as => :user_session get 'signup' => 'devise/registrations#new', :as => :new_user post 'signup' => 'devise/registrations#create', :as => :create_user_session delete 'signout' => 'devise/sessions#destroy', :as => :destroy_user_session get "/account" => "devise/registrations#edit" end 
+4
source share
2 answers

I think the problem is that you incorrectly specified post 'signup' . Which way is your POST user registration form on?

 post 'signup' => 'devise/registrations#create', :as => :create_user_session 

Must be:

 post 'signup' => 'devise/registrations#create', :as => :user_registration 

Here is a look at my routes.rb that solved this problem:

 as :user do get "/signin" => "devise/sessions#new", :as => :new_user_session post "/signin" => "devise/sessions#create", :as => :user_session delete "/signout" => "devise/sessions#destroy", :as => :destroy_user_session get "/signup" => "devise/registrations#new", :as => :new_user_registration post '/signup' => 'devise/registrations#create', :as => :user_registration end 
+3
source

It does not redirect you anywhere, these are the URLs that contain error messages.

If you want to edit these URLs, see the wiki for a good starting point: https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes

-2
source

All Articles