undefined local variable or method `config' for main:Object - rails

后端 未结 3 515
后悔当初
后悔当初 2021-01-18 08:13

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

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

How c

相关标签:
3条回答
  • 2021-01-18 08:50

    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.

    0 讨论(0)
  • 2021-01-18 08:51

    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.

    0 讨论(0)
  • 2021-01-18 08:54

    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
    
    0 讨论(0)
提交回复
热议问题