RAILS_ROOT require?

mportiz08 picture mportiz08 · May 29, 2010 · Viewed 10.2k times · Source

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?

Answer

Leventix picture Leventix · May 29, 2010

Yes, you should require the environment.rb:

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

And Rails.root instead.