root() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Show source
Register or log in to add new notes.
June 4, 2009
2 thanks

example

Ruby style

Dir[File.join(RAILS_ROOT, 'vendor', 'plugins', '*')]

Rails style

Dir[Rails.root.join('vendor', 'plugins', '*')]
February 25, 2010
2 thanks

Possible gotcha

This method returns a Pathname object which handles paths starting with a / as absolute (starting from the root of the filesystem). Compare:

>> Rails.root
=> #<Pathname:/some/path/to/project>
>> Rails.root + "file"
=> #<Pathname:/some/path/to/project/file>
>> Rails.root + "/file"
=> #<Pathname:/file>
>> Rails.root.join "file"
=> #<Pathname:/some/path/to/project/file>
>> Rails.root.join "/file"
=> #<Pathname:/file>