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
Andy Stewart, 16 August 2007

Posted in Deployment, Notes To Self, Rails


Have your say

You can use Markdown in your comments. If you want to post code, do this:

<pre><code class="ruby|javascript|css|html">your code here</code></pre>

Thanks!