在环境特定的配置文件中配置未定义

Nic*_*o77 2 ruby ruby-on-rails

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

please set config.active_support.deprecation to :log at config/environments/development.rb
Run Code Online (Sandbox Code Playgroud)

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

config.active_support.deprecation = :log 
Run Code Online (Sandbox Code Playgroud)

我明白了:

undefined local variable or method `config' for main:Object (NameError)
Run Code Online (Sandbox Code Playgroud)

我的环境:Rails 3.0.1 Ruby 1.8.7 Ubuntu 10.04

Development.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
Run Code Online (Sandbox Code Playgroud)

小智 11

在你的development.rb中它应该有一个看起来像这样的块:

YourApplicationName::Application.configure do
   config.active_support.deprecation = :log
   config.cache_classes = false
end
Run Code Online (Sandbox Code Playgroud)

配置行必须放在该块内.