Domanda

I'm familiar with the Rails.root in Rails which tells you the directory of your current application. This is quite handy sometimes.

Now I'm developing a Rack application (on which Rails is based). How do I find out the Rails.root equivalent for a Rack application?

Thank you.

È stato utile?

Soluzione

This returns the root directory in a string.

Rack::Directory.new('').root

Not sure if there's a better, shorter syntax.

Altri suggerimenti

What worked for me is a simple File.expand_path:

File.expand_path(File.join("log", "some_file_#{ENV["RACK_ENV"] || "development"}.log"))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top