Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试访问位于 /lib 目录中的文件中的 RAILS_ROOT 常量,但我无法访问(未初始化的常量错误)。我需要做些什么才能做到这一点吗?
是的,您应该需要 environment.rb:
require File.dirname(__FILE__) + '/../config/environment.rb' puts RAILS_ROOT
Rails.root相反。
Rails.root