Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

NoMethodError (undefined method `new_user_session_path' for #<Devise::FailureApp:0x000001070fc870>) #1312

Closed
tapajos opened this Issue · 7 comments

2 participants

Marcos Tapajós José Valim
Marcos Tapajós

I'm getting this error when my model doesn't use database_authenticatable.

Devise version: 1.4.1.

class User < ActiveRecord::Base
  devise :rememberable, :omniauthable, :token_authenticatable, :trackable
end
(tapajos:fundos (feature/show))$ rake routes
user_omniauth_callback        /users/auth/:action/callback(.:format) {:action=>/myfcid/, :controller=>"users/omniauth_callbacks"}
                              /:controller(/:action(/:id(.:format))) 
class User < ActiveRecord::Base
  devise :database_authenticatable, :rememberable, :omniauthable, :token_authenticatable, :trackable
end
(tapajos:fundos (feature/show))$ rake routes
[2011-09-02 12:50:23][HireFire] Delayed::Backend::ActiveRecord::Job detected!
      new_user_session GET    /users/sign_in(.:format)               {:action=>"new", :controller=>"devise/sessions"}
          user_session POST   /users/sign_in(.:format)               {:action=>"create", :controller=>"devise/sessions"}
  destroy_user_session GET    /users/sign_out(.:format)              {:action=>"destroy", :controller=>"devise/sessions"}
user_omniauth_callback        /users/auth/:action/callback(.:format) {:action=>/myfcid/, :controller=>"users/omniauth_callbacks"}
                              /:controller(/:action(/:id(.:format))) 
José Valim
Owner

We don't generate the sessions controller (and consequently the session routes) if the strategies to your model don't require one. So you need to inherit from Devise::FailureApp and create your own FailureApp with the correct instructions in case of failures. Maybe we could automatically detect such cases and raise warning instead of letting it explode on runtime.

José Valim
Owner

You probably just want to override that method to redirect to the home page. Alternatively, you can define new_user_session_path manually in your routes.rb and make it point to the home as well.

Marcos Tapajós
José Valim
Owner

Yes. It was a bug that was fixed.

José Valim
Owner

Maybe we could check if new_user_session_path exists and if not, redirect to root_path. This way it would work out of the box, what do you think?

Marcos Tapajós
José Valim josevalim closed this in 7b0a8f9
Adrian Dulić adriandulic referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.