Is it possible to know the Rails file system root of an application in the code of a gem included in an app?
This is a sample of the gem source:
module MyGem
def self.included(base)
puts Rails.root # return nil
end
end
ActionController::Base.send :include, MyGem
Thank’s and sorry for my poor english
The solution that I found to fix a similar problem to this is to include my module using the railtie initializers.
So, in your /lib/mygem/railtie.rb
With this code, your module will be included after the ActionController is loaded and you will be able to use Rails.root
Let me know if this works for you.