Kashiftufail
Kashiftufail

Reputation: 10885

How can I change the default behavior of redirects in Devise

I have this in my route file:

 devise_scope :user do
   get "/admin", :to => "users/sessions#new"
 end

I can access the sing in form by going to http://localhost:3000/admin. When I click on Sign in without providing username and password it redirects me to the /users/sign_in path with error message about missing username and password.

I think it is default behavior of Devise. But on sing in error, I want be redirected to the /admin instead of default /users/sign_id. How can I achieve this behavior?

Thanks in advance.

Upvotes: 1

Views: 206

Answers (1)

Ernest
Ernest

Reputation: 8829

  devise_for :users
  as :user do
    get 'admin' => 'devise/sessions#new', :as => :new_user_session
    post 'admin' => 'devise/sessions#create', :as => :user_session
  end

Upvotes: 2

Related Questions