配置在特定于环境的配置文件中未定义 [英] config undefined in environment specific configuration files

查看:57
本文介绍了配置在特定于环境的配置文件中未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I start my server locally, I get the following notice:

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

当我添加 config/environments/development.rb 时

When I add in 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

my environment: Rails 3.0.1 Ruby 1.8.7 Ubuntu 10.04

Development.rb 文件

Development.rb file

# 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

推荐答案

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

In your development.rb it should have a block that looks like:

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

配置行必须放在那个块内.

The config lines must be placed inside that block.

这篇关于配置在特定于环境的配置文件中未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆