Rails: is there an Engine.root?

Rails.root returns a Path object specifying the root of a Rails project.

Is there an equivilent for Rails engines? Like Engine.root? If not, how else could I build up a path from the root of my Rails engine?


Solution 1:

Lets say your engine file is set up like this:

module MyEngine
  class Engine < Rails::Engine
    #......
  end
end

You can call root on the Engine class like this:

MyEngine::Engine.root