Unshift + file.join in ruby

$:.unshift File.join(File.dirname(__FILE__),\ 'vendor','addressable-2.1.0','lib','addressable','uri') 

Does the code provide access to a file that has this path:

 'vendor/addressable-2.1.0/lib/addressable/uri' 

I am trying to transfer an addressable stone to a Sinatra application to deploy it to my hosting provider, but I keep getting:

 "no such file to load -- addressable/uri" 

after putting the string < unshift in config.ru .

+2
ruby file
Sep 08 '09 at 18:53
source share
2 answers

In the above code, the path "vendor / addressable-2.1.0 / lib / addressable / uri" is added to the global variable used to search for external files. The path will refer to the directory in which the file in which this code is located is located. Thus, the config.ru directory was placed {dir}, it will add {dir}/vendor/addressable-2.1.0/lib/addressable/uri to the search path for include.

+3
Sep 08 '09 at 19:01
source share

What the line does is the path "vendor / addressable-2.1.0 / lib / addressable / uri" (relative to the directory in which the ruby ​​script is located), to the boot path, which is a list, the rubies directories look at when looking for the required files.

The string itself will not try to access any files.

0
Sep 08 '09 at 19:02
source share



All Articles