Load resource relative to required file?

Discussion in 'Ruby' started by walter@mwsewall.com, Jul 22, 2003.

  1. Guest

    I looked in the faq and I couldn't find my answer or a searchable
    archive for the mailing list (so if anyone has that it would be
    great).

    I have a 1st.rb file that loads an xml configuration file that is in
    the same directory. I have 2nd.rb file that uses the 1st.rb file via
    require. Everything was fine when they were in the same directory,
    but when I put 1st.rb in a subdirectory, it no longer loads its .xml
    file (which has also moved to the subdirectory). I get a "No such
    file or directory" error.

    So the question is, how does one load a resource relative to the
    actual file, and not the file that required it?


    Walt

    *****************************************************
    Walter Szewelanczyk
    IS Director
    M.W. Sewall & CO. email :
    259 Front St. Phone : (207) 442-7994 x 128
    Bath, ME 04530 Fax : (207) 443-6284
    *****************************************************
    , Jul 22, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dirc Khan-Evans
    Replies:
    1
    Views:
    892
    Karl Seguin
    Oct 17, 2005
  2. avishosh
    Replies:
    2
    Views:
    10,567
    avishosh
    Aug 8, 2004
  3. Heinrich Moser
    Replies:
    1
    Views:
    456
    Heinrich Moser
    Mar 27, 2008
  4. LB
    Replies:
    1
    Views:
    848
  5. torontodesi
    Replies:
    0
    Views:
    1,119
    torontodesi
    Feb 25, 2009
Loading...

Share This Page