I'm getting the error uninitialized constant SessionsController
I've searched, and can only find explanations of this error in reference to a NameError
Does anyone know what the error means?
Asked
Active
Viewed 7,400 times
1

Arel
- 3,888
- 6
- 37
- 91
-
3It means exactly what it says, that the variable by that name is uninitialized. It's referring to it as a constant because it's capitalized. – Peter Alfvin Sep 27 '13 at 18:31
-
Can you elaborate a little bit? SessionsController is supposed to be capitalized. – Arel Sep 27 '13 at 18:39
-
Right. But it hasn't been defined yet. This is a standard error message for any attempt to access a capitalized variable that is undefined. – Peter Alfvin Sep 27 '13 at 18:49
-
1If you thought it _should_ have been defined, you'll have to share some code and assert why you believe that to be the case. – Peter Alfvin Sep 27 '13 at 18:49
-
That's fine, I have another questions that is specifically about solving the error. I just wanted to know what the error message specifically meant so I could better understand what was going on. http://stackoverflow.com/questions/19057217/uninitialized-constant-sessionscontroller-in-api/19058081#19058081 – Arel Sep 27 '13 at 18:51
2 Answers
3
It means that you're trying to use a Class or a Module that wasn't defined yet. Probably because you forgot to require them.
Make sure that this class SessionsController
has been declared in your sessions_controller.rb
.
Read more: http://ruby.about.com/od/faqs/qt/Nameerror-Uninitialized-Constant-Object-Something.htm

Daniel Pereira
- 327
- 2
- 8
3
That is one of two "subtypes of" Name Error
dealing with uninitialized variables. The language of "uninitialized constant" is due to the fact that SessionsController
is capitalized. Both types are illustrated below:
new-host-3:bot palfvin$ irb
2.0.0p247 :001 > foobar
NameError: undefined local variable or method `foobar' for main:Object
from (irb):1
from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/bin/irb:16:in `<main>'
2.0.0p247 :002 > Foobar
NameError: uninitialized constant Foobar
from (irb):2
from /Users/palfvin/.rvm/rubies/ruby-2.0.0-p247/bin/irb:16:in `<main>'
2.0.0p247 :003 >

Peter Alfvin
- 28,599
- 8
- 68
- 106