Rails Root directory path?
For super correctness, you should use:
Rails.root.join('foo','bar')
which will allow your app to work on platforms where /
is not the directory separator, should anyone try and run it on one.
In Rails 3 and newer:
Rails.root
which returns a Pathname
object. If you want a string you have to add .to_s
. If you want another path in your Rails app, you can use join
like this:
Rails.root.join('app', 'assets', 'images', 'logo.png')
In Rails 2 you can use the RAILS_ROOT
constant, which is a string.