[英]what is the the difference between #{path} and “#{RAILS_ROOT}”
I know that RAILS_ROOT
is the old way of getting Rails.root
and that it returns a string while Rails.root
returns a Pathname object. 我知道
RAILS_ROOT
是获取Rails.root
的旧方法,它返回一个字符串,而Rails.root
返回一个Pathname对象。 I have had issues using RAILS_ROOT
before loading the environment. 在加载环境之前,我遇到过使用
RAILS_ROOT
的问题。 As a quick solution I use #{path}
which works and returns also the root path as a tring. 作为一个快速的解决方案,我使用
#{path}
工作,并返回根路径作为tring。 I have also noticed that while RAILS_ROOT
and Rails.root work as expected on console, #{path}
does not. 我还注意到,虽然
RAILS_ROOT
和Rails.root在控制台上按预期工作,但#{path}
却没有。
So what is this #{path}
and where does it come from? 那么
#{path}
是什么?它来自哪里?
To my knowledge there is not a "path" variable set by default. 据我所知,默认情况下没有设置“路径”变量。 Do a search on your code base for "path" and see where it is being set.
在代码库中搜索“path”并查看其设置位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.