Rails 3.0.0, Devise 1.1.3, undefined_method 'new_application_user_session_path', routes not being shown #614

Closed
johnnyicon opened this Issue Nov 3, 2010 · 17 comments

Projects

None yet

2 participants

@johnnyicon

I followed the instructions in the README to get set up, except I installed Devise by adding gem 'devise' to my Gemfile. It installed 1.1.2.

I tried access a protected controller and received this error.

undefined method 'new_application_user_session_path' for #<Devise::FailureApp::0x60aldc0>

Updated to 1.1.3 by modifying my Gemfile to gem 'devise', '1.1.3'. I tried accessing the same controller and got the same error.

I should also mention that I do not see the routes when I run rake routes.

My routes.rb: http://pastie.org/1270337
My Gemfile: http://pastie.org/1270450
My migration file: http://pastie.org/pastes/1270573

NOTE: In case anyone is wondering, I will be authenticating using LDAP. So that's why you don't see t.database_authenticatable

My model file application_user.rb: http://pastie.org/pastes/1270586
My devise.rb initalizer file: http://pastie.org/pastes/1270597

NOTE: Because I will be authenticating against LDAP, I am using a different column other than the default email column that Devise defaults to. As a result, I had to install the Devise views (rails g devise:views) and modify the app/views/devise/session/new.html.erb file to use user_ldap_id instead of email.

NOTE: I removed any irrelevant code from these snippets.

@slbug
Contributor
slbug commented Nov 3, 2010

have you added devise_for :user in routes?

@johnnyicon

Yep! The rails g devise MODEL command will do that for you.

@slbug
Contributor
slbug commented Nov 3, 2010

can you provide some test app maybe?

@johnnyicon

I'll do that tonight, but I'll also provide more detail in this ticket.

@johnnyicon

I added my routes.rb and Gemfile.

@johnnyicon

I added all the files that are relevant to Devise, except for the session/new.html.erb file that I had to modify. I simply changed :email to :user_ldap_id.

@slbug
Contributor
slbug commented Nov 3, 2010

there is no new_application_user_session_path (and sign_in route) because model dont have :database_authenticatable

@johnnyicon

So even though I don't need it, I have to include it for Devise to work?

@slbug
Contributor
slbug commented Nov 3, 2010

yea if you using only devise, but check this out https://github.com/cschiewek/devise_ldap_authenticatable it will add :ldap_authenticatable instead of :database_authenticatable

@johnnyicon

Nice. So I installed Devise LDAP Authenticatable and now the routes are showing. However, accessing the protected controller again, I get an error saying:

undefined constant ApplicationController::DeviseLdapAuthenticatable

This is coming from the lines that Devise LDAP Authenticatable injects into my ApplicationController to catch a DeviseLdapAuthenticatable::LdapException. This is not entirely necessary at the moment, so I comment it out.

I check my routes again, just to be sure they're still there, and they are. So I try accessing my protected controller again, and I'm getting the same error as before.

I just want to test this out and see the sign-in page. That way I know that Devise is working. The LDAP side of things I'll worry about later.

@slbug
Contributor
slbug commented Nov 3, 2010

http://github.com/slbug/ldaptest

wecome controller is protected. it redirects to sign_in page.

@johnnyicon

I don't see anything in your Gemfile, so I'm assuming you installed the gem directly (i.e., gem install). Is this important?

@slbug
Contributor
slbug commented Nov 4, 2010

https://github.com/slbug/ldaptest/blob/master/Gemfile check once again. it always was here.

@johnnyicon

Sorry. It's been a late night. I'll take a closer look.

@johnnyicon

Comparing your routes.rb against mine, is it important to remove existing resource definition for application_user? More specifically, I have both a devise_for :application_users and a resources :application_users in mine. Do I need to get rid of the latter?

@slbug
Contributor
slbug commented Nov 4, 2010

if resources defined after devise_for then everything should be ok

@johnnyicon

That worked! Thanks!

Though simply restarting the server didn't seem to apply the changes. For whatever reason, I had to stop the server, cd out of my project directory, and then start the server again.

Thanks again for all the help. Really appreciate it!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment