Daniel DeLorme
1/28/2007 1:28:00 PM
Daniel Berger wrote:
> phil.swenson@gmail.com wrote:
>> I'm trying to find the full path to a file. File.dirname(__FILE__)
>> always returns ".", which doesn't really do me any good. The working
>> directory is not always the same as where the file is, so I can't use
>> the "." in any useful way.
>
> I think you want File.expand_path(File.dirname(__FILE__))
I tend to use this idiom a lot:
require File.expand_path(__FILE__+'/../relative/path/to/file')
For ruby, "file" and "dummydir/../file" are considered as 2 different
files, so I think it's a good idea to always use absolute directories
when doing a require.
Daniel