In Rails programming you might seldom come across the below statement
$:.unshift File.dirname(__FILE__)
$: represents load path in Ruby.
Its a pre-defined variable and short hand for $LOAD_PATH which ruby uses to look for files.
unshift prepends the given path to the beginning of the array (load path).
__FILE__
gives the relative path of the file from the current execution directory.
Incase, you need absolute path, use
File.expand_path(__FILE__)
NOTE : This explanation is as of Ruby 1.8.6. Latest versions of Ruby behave differently.
Posted by Sandheep to Sandheep's deck (2013-04-25 14:27)