From: luke gruber Date: 2011-11-05T03:12:29+09:00 Subject: Re: 'require' problem > Sam Rose wrote in post #1030126: > If you're not on 1.9.2 and don't have require_relative, I believe this > require './string_extensions' The problem with doing something like this is that the requiring file will only find the required file when the program's invoked from that directory. For example, if you move back one directory and then try to run it, it won't work. It's a good idea to make scripts as portable as possible, so something like this would be a good idea, I think. require File.join(File.expand_path(File.dirname(__FILE__)), 'string_extensions') What this means: __FILE__ is a string of the current filename File.dirname(f) gets the directory of f File.expand_path(f) expands things like "~" and "." File.join(*files) joins all the files with whatever file separating character is appropriate on your system. Ex: '/', '\' As much as this might seem like overkill, it might be a good habit to get into because LoadErrors are annoying as hell. -Luke -- Posted via http://www.ruby-forum.com/.