Hi
How do I get the directory where the rakefile.rb is located?
I want to use this as my root directory to locate everything off.
Cheers
Hi
How do I get the directory where the rakefile.rb is located?
I want to use this as my root directory to locate everything off.
Cheers
If this is a RoR app your Rakefile.rb should be in your RAILS_ROOT directory. So in any script you can specify file location like
config.load_paths += %W( #{RAILS_ROOT}/extras )
use __FILE__
to get the file name then you can get the directory from there:
in test.rb
puts __FILE__
output:
/users/foo/test.rb
__FILE__
resolves to the full path of the file it is in.
Use this to get the dir name:
File.dirname(__FILE__)
You can get it by calling application.original_dir method. In task you can achieve application object using application method on task object.