Search code examples
ruby-on-railsuninitialized-constant

What does uninitialized constant mean?


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?


Solution

  • 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 >