[英]RAILS_ROOT require?
I'm trying to access the RAILS_ROOT constant in a file residing in the /lib directory, but I'm not able to (uninitialized constant error). 我正在尝试访问驻留在/ lib目录中的文件中的RAILS_ROOT常量,但我无法(未初始化的常量错误)。 Is there something that I need to require to be able to do this?
有什么我需要能够做到这一点吗?
Yes, you should require the environment.rb: 是的,您应该要求environment.rb:
require File.dirname(__FILE__) + '/../config/environment.rb'
puts RAILS_ROOT
And Rails.root
instead. 和
Rails.root
相反。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.