Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Designing URLs Creating Custom Routes

Seth Reece
Seth Reece
32,867 Points

For login and logout I get uninitialized constant Devise::SesssionsController error

In my routes file I have:

Treebook::Application.routes.draw do
  devise_for :users, :controllers => { registrations: 'registrations' }

  devise_scope :user do 
    get 'register', to: 'devise/registrations#new', as: :register
    get 'login', to: 'devise/sesssions#new', as: :login
    get 'logout', to: 'devise/sesssions#destroy', as: :logout
  end
  devise_for :views
  resources :statuses
  root to: 'statuses#index'
Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Are you using the same versions of all gems as the project does? Such as old versions of Rails and Devise?

Seth Reece
Seth Reece
32,867 Points

No I'm not. I tried creating a sessions_controller.rb file and adding , sessions: 'sessions' to the devise_for line. The routes show up fine in rake routes from devise_scope. Based on the documentation, I should be heading the right direction.

2 Answers

Seth Reece
Seth Reece
32,867 Points

My own answer:

Had to add private code at bottom of sessions_controller:

class Sessions::SessionsController < Devise::SessionsController
 before_filter :configure_sign_in_params, only: [:create]


   def new
    super
   end


  def create
    super
  end


  private

  def configure_sign_in_params 
    devise_parameter_sanitizer.sanitize(:sign_in)
  end
end

works pretty good now.

oh yeah, and change devise_for to:

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

I had this exact same error. Tried a few things, nothing worked. Then i saw a weird similarity between our 2 codes. We both have 3 s's in sesssionscontoller. So, i changed it to 2 s's, like it should be and all worked, fine. :P