Routing error - uninitialized constant

Davit picture Davit · Apr 6, 2013 · Viewed 53k times · Source

I could not fix this in Rails 3.2.12, maybe I am missing something.

config/routes.rb

get "home/index"
root :to => "home#index"
devise_for :users, :only => :omniauth_callbacks
match 'users/auth/:provider/callback' => 'authentications#create'
match '/auth/:provider/signout' => 'authentications#signout'

app/controllers/authentication_controller.rb

class AuthenticationsController < ApplicationController
  ...
end

app/models/authentication.rb

class Authentication < ActiveRecord::Base
  ...
end

I think it should work with my current knowledge, but there is something that I miss.

My kind question would be to tell what is wrong, please.

Rounting Error

uninitialized constant AuthenticationsController

This is a message that shows up at http://localhost:3000/auth/facebook/signout

Answer

alf picture alf · Apr 6, 2013

Rails requires the file name to match the class name. Therefore you should rename app/controllers/authentication_controller.rb to app/controllers/authentications_controller.rb.