RAILS_ROOT require?

后端 未结 1 1671
伪装坚强ぢ
伪装坚强ぢ 2021-02-12 16:51

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:04

    Yes, you should require the environment.rb:

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

    And Rails.root instead.

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