1

I want to use token_authenticatable in my application (using Devise).

Using this answer I added class Users::SessionsController in file app/controllers/users_sessions_controller.rb (is file location correct?).

To generate authentication_token in database I added line current_user.reset_authentication_token! as fourth line of create method.

Using "Configuring Controllers" section from devise docimentation I added line devise_for :users, :controllers => {:sessions => "users/sessions"} to my routes.

I also have file app/views/users/session/new.html.erb.

Now when I try to log in or log out in browser, I get Routing Error uninitialized constant Users.

I have no idea what happens. I think I named controller class wrong, or placed it incorrectly, but don't know for sure.

Community
  • 1
  • 1
Mateusz
  • 1,149
  • 1
  • 16
  • 33

1 Answers1

3

If you want your controller named Users::SessionsController then it need to be in app/controllers/users/sessions_controller.rb

If you don't want nested folders for your controllers you could also do

class UserSessionsController 

located at app/controllers/user_sessions_controller.rb with the routes being: devise_for :users, :controllers => {:sessions => "user_sessions"}

Kyle d'Oliveira
  • 6,382
  • 1
  • 27
  • 33