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

时间:2023-01-12 23:35:03

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

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

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

When I add in config/environments/development.rb

当我添加配置/环境/开发时

config.active_support.deprecation = :log 

I get:

我得到:

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

my environment: Rails 3.0.1 Ruby 1.8.7 Ubuntu 10.04

我的环境:Rails 3.0.1 Ruby 1.8.7 Ubuntu 10.04

Development.rb file

发展。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

3 个解决方案

#1


11  

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

在你的发展。rb应该有这样一个block:

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

The config lines must be placed inside that block.

配置行必须放在该块中。

#2


1  

Make sure you add the line where the other config.* options are - inside the *.configure loop.

确保您添加了另一个配置的行。*选项在*内。配置循环。

#3


0  

Try this

试试这个

 rails s -e development

#1


11  

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

在你的发展。rb应该有这样一个block:

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

The config lines must be placed inside that block.

配置行必须放在该块中。

#2


1  

Make sure you add the line where the other config.* options are - inside the *.configure loop.

确保您添加了另一个配置的行。*选项在*内。配置循环。

#3


0  

Try this

试试这个

 rails s -e development