This works for my rack application:
$: << File.expand_path(File.dirname(FILE))
require “some_file”
…
However if I comment this out the first line, i.e.
$: << File.expand_path(File.dirname(FILE))
then the file some_file.rb cannot be found and web-server (mongrel)
complains.
How can I adjust the path at the system level where I don’t have to put
the line:
$: << File.expand_path(File.dirname(FILE))
at the top of each ruby file that requires some other ruby file?
Thanks for your time.
Bharat
On 01/07/2011 02:26 PM, Bharat R. wrote:
then the file some_file.rb cannot be found and web-server (mongrel)
complains.
How can I adjust the path at the system level where I don’t have to put
the line:
$: << File.expand_path(File.dirname(FILE))
at the top of each ruby file that requires some other ruby file?
I don’t know much about Rack applications, but it sounds like you might
be using Ruby 1.9. If so, have you tried replacing your problematic
require calls with require_relative?
You might also look to the configuration of the HTTP server hosting your
Rack application and see if you can set the RUBYLIB environment variable
to include the path to the directory containing some_file.
Hopefully, someone with actual experience using Rack can provide better
help.
-Jeremy