Forum: Ruby on Rails $:.unshift File.join(File.dirname(__FILE__),'..','lib')?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C5559084a7e35faed422d1d016abede9?d=identicon&s=25 MohsinHijazee (Guest)
on 2008-02-12 11:14
(Received via mailing list)
What this code lines mean? Especially $:. before the unshift?

$:.unshift File.join(File.dirname(__FILE__),'..','lib')

Regards,
Mohsin
2d8132658d56e51f19ace1c68e48b6aa?d=identicon&s=25 Thorsten Mueller (thorsten)
on 2008-02-12 11:32
MohsinHijazee wrote:
> What this code lines mean? Especially $:. before the unshift?
>
> $:.unshift File.join(File.dirname(__FILE__),'..','lib')
>
> Regards,
> Mohsin

ruby comes with a set of predefined variables

$: = default search path (array of paths)
__FILE__ = current sourcefile

if i get it right (not 100% sure) this adds the lib path to this array
of search paths by going over the current file. which is not exactly the
best way, i would simply start with RAILS_ROOT (at least for a rails
project)
This topic is locked and can not be replied to.