7

When I run the rails application, I get the following error:

undefined local variable or method "config" for main:Object

How can I resolve it?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
user1179589
  • 71
  • 1
  • 2
  • Is this displaying in the console, or a log? Please post the entire backtrace. Also post the code which the backtrace points you to. – Alex D Jan 31 '12 at 05:38
  • 2
    I don't know anything about Ruby on Rails, but I know enough about programming to know that good programming questions should include code. – Cody Gray - on strike Jan 31 '12 at 05:54

3 Answers3

5

My guess is that you found some code examples from an older version of rails, which called for you to place a config.gem * in your environment.rb file. To fix this add the gem requirement to your gemfile.

jimmiebtlr
  • 438
  • 4
  • 14
1

in your enviroment.rb file, cut any line starting with config and paste into your production.rb/development.rb/test.rb instead.

This is what worked for me when I had a similar problem.

The Ref
  • 684
  • 2
  • 7
  • 20
0

I had this problem when an application had been upgraded from Rails 2 to Rails 3. It worked in development but I got this error when running in production mode for the first time because config/environments/production.rb contained Rails 2-style lines such as:

config.cache_classes = true

..which needed converting to Rails 3-style:

<<NameOfYourApp>>::Application.configure do

  config.cache_classes = true
end