在config.paths.log中未定义log方法

时间:2015-01-27 05:44:05

标签: ruby-on-rails

我想限制日志大小并放置此行

config.logger = Logger.new(config.paths.log.first, 1, 5.megabytes)

development.rb

中的

没有运气,我得到了未定义的方法错误

config.paths.log
NoMethodError: undefined method `log' for #<Rails::Paths::Root:0x007fa5c1de7308>

转储config.paths

[3] pry(#<COT::Application>)> config.paths
#<Rails::Paths::Root:0x007fa5c1de7308 @current=nil, 
... 
"log"=>#<Rails::Paths::Path:0x007fa5c1de5c38 @paths=["log/development.log"], @current="log", @root=#<Rails::Paths::Root:0x007fa5c1de7308 ...>

1 个答案:

答案 0 :(得分:2)

尝试

config.paths['log'].first

而不是

config.paths.log.first 

参考:config.logger and config.paths.log in Rails 3