path unshift dirname of file

31 Aug 2015

Instead of using:

$:.unshift File.dirname(__FILE__)

to add a folder to the path, a better way inside your ruby code is to use:

require_relative 'subfolder/file'

in order to require files. You can also use a relative path in require (i.e. ‘./subfolder/file’).



Do you want to send a comment or give me a hint about any issues with a blog post: Open up an issue on GitHub.

Do you want to fix an error or add a comment published on the blog? You can do a fork of this post and do a pull request on github.