This returns the root directory in a string.
Rack::Directory.new('').root
Not sure if there's a better, shorter syntax.
Question
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.
Solution
This returns the root directory in a string.
Rack::Directory.new('').root
Not sure if there's a better, shorter syntax.
OTHER TIPS
What worked for me is a simple File.expand_path
:
File.expand_path(File.join("log", "some_file_#{ENV["RACK_ENV"] || "development"}.log"))