Hi,
How do I get the directory path of the file that is currently
executing?
Also, if I have a module, within a function, how do I get the parent
directory (full path) of that module?
Thanks
Javi
Printable View
Hi,
How do I get the directory path of the file that is currently
executing?
Also, if I have a module, within a function, how do I get the parent
directory (full path) of that module?
Thanks
Javi
I've never done it so I don't know for sure, but I've seen lines like
so I'm guessing there's a way to use __FILE__ to get the full path similar to getting the directory name.Code Ruby:RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
You should be able to use the Dir class.
http://ruby-doc.org/core/classes/Dir.htmlCode:Dir.pwd