RAILS_ROOT require?

后端 未结 1 504
天涯浪人
天涯浪人 2021-02-12 16:35

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 re

相关标签:
1条回答
  • 2021-02-12 17:13

    Yes, you should require the environment.rb:

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

    And Rails.root instead.

    0 讨论(0)
提交回复
热议问题