【问题标题】:config undefined in environment specific configuration filesconfig undefined 在特定于环境的配置文件中
【发布时间】:2012-10-14 01:59:18
【问题描述】:

当我在本地启动服务器时,我收到以下通知:

please set config.active_support.deprecation to :log at config/environments/development.rb

当我添加 config/environments/development.rb

config.active_support.deprecation = :log 

我明白了:

undefined local variable or method `config' for main:Object (NameError)

我的环境: Rails 3.0.1 Ruby 1.8.7 Ubuntu 10.04

开发.rb 文件

# Settings specified here will take precedence over those in config/environment.rb

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.active_support.deprecation = :log
config.cache_classes = false

【问题讨论】:

    标签: ruby-on-rails ruby


    【解决方案1】:

    在你的 development.rb 中应该有一个如下所示的块:

    YourApplicationName::Application.configure do
       config.active_support.deprecation = :log
       config.cache_classes = false
    end
    

    配置行必须放在该块内。

    【讨论】:

      【解决方案2】:

      确保在 *.configure 循环中添加其他 config.* 选项所在的行。

      【讨论】:

      • 我很困惑。任何 confing.* 都会在 config/environments/development.rb 文件中给出相同的错误
      • 你能发布部分/全部你的 development.rb 文件吗?
      【解决方案3】:

      试试这个

       rails s -e development
      

      【讨论】:

        猜你喜欢
        • 2016-02-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-11
        • 1970-01-01
        • 2021-01-22
        • 2014-03-03
        • 1970-01-01
        相关资源
        最近更新 更多