Reputation: 393
I've created custom routes to route to the devise login and logout paths:
devise_scope :admin do
get "logout" => "devise/sessions#destroy", as: :logout
get "login" => "devise/sessions#new", as: :login
end
This works. The only problem is that if the the login fails it redirects back to admins/sign_in
instead of /login
.
Any ideas?
Upvotes: 1
Views: 1823
Reputation: 11082
According to this answer and this description, it seems the proper way to achieve what you're attempting to do is to make use of the :path_names
option. According to the description from the Devise wiki:
devise_for :admin, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout'}
will create the normal admin
routes for you, and will assign the /sign_in
and /sign_out
route to /login/
and /logout
respectively.
Using the :path
option, you can further alter the URL, such as using :path=>"admins"
will yield routes like /admin/login
, etc.
Upvotes: 4