Note To Self: Beware Relative Paths

When loading my own Ruby sources into Rails in environment.rb, don’t do this:

require 'my_library'

Do this:

require File.join(File.dirname(__FILE__), '../lib/my_library')

Especially when using a cheap host that:

  • starts up Rails in a directory that isn’t the app’s root
  • doesn’t give you access to the error logs
Andrew Stewart • 16 August 2007 •

Got a question or comment? or .