RAILS_ROOT require?

我们两清 提交于 2019-12-04 16:49:08

问题


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). Is there something that I need to require to be able to do this?


回答1:


Yes, you should require the environment.rb:

require File.dirname(__FILE__) + '/../config/environment.rb'
puts RAILS_ROOT

And Rails.root instead.



来源:https://stackoverflow.com/questions/2933225/rails-root-require

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