simo
simo

Reputation: 24558

overriding devise controllers

I am trying to override two controllers for devise, but, as a result, only first listed controller in routes.rb is overriden

  devise_for :users, :controllers => { :sessions => "users/sessions" }
  devise_for :users, :controllers => { :registrations => "users/registrations" }

What I get is:

new_user_session GET    /users/sign_in(.:format)                             users/sessions#new
                             user_session POST   /users/sign_in(.:format)                             users/sessions#create
                     destroy_user_session DELETE /users/sign_out(.:format)                            users/sessions#destroy
                            user_password POST   /users/password(.:format)                            devise/passwords#create
                        new_user_password GET    /users/password/new(.:format)                        devise/passwords#new
                       edit_user_password GET    /users/password/edit(.:format)                       devise/passwords#edit
                                          PUT    /users/password(.:format)                            devise/passwords#update
                 cancel_user_registration GET    /users/cancel(.:format)                              devise/registrations#cancel
                        user_registration POST   /users(.:format)                                     devise/registrations#create
                    new_user_registration GET    /users/sign_up(.:format)                             devise/registrations#new
                   edit_user_registration GET    /users/edit(.:format)                                devise/registrations#edit
                                          PUT    /users(.:format)                                     devise/registrations#update
                                          DELETE /users(.:format)                                     devise/registrations#destroy

if I list registrations controller first, it will work, but sessions controller wont ,,

Any idea ?

Upvotes: 1

Views: 497

Answers (1)

HungryCoder
HungryCoder

Reputation: 7616

The way you defined the routes won't work. As rails will go for first matched routing. You can re-write that as follows:

devise_for :users, :controllers => { :sessions => "users/sessions", :registrations => "users/registrations" }

Then it should work.

Upvotes: 1

Related Questions