config.logger and config.paths.log in Rails 3

巧了我就是萌 提交于 2019-12-24 09:48:18

问题


I get this error when trying to start the server.

logger.rb:541:in `exist?': can't convert Rails::Paths::Path into String (TypeError)

This is the code in my development.rb.

require 'log_formatter'
config.logger = Logger.new(config.paths.log.first)
config.logger.formatter = LogFormatter.new
config.logger.level = Logger::DEBUG

I have tried adding .to_s, but it's no use.

Google is no help either.


回答1:


Try

config.logger = Logger.new(config.paths.log.first.path)

http://api.rubyonrails.org/classes/Rails/Paths/Path.html




回答2:


In Rails 3.1.1 the old syntax has been deprecated. You should now use:

config.paths['log'].first


来源:https://stackoverflow.com/questions/4268525/config-logger-and-config-paths-log-in-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!