> Kent Dahl wrote: > >> Sean O'Dell wrote: >> >>> Oh, did I use require in my example...oops. Yes, I use load, require >>> doesn't work. The problem isn't loading the module, it's using >>> functions within a module. When I call functions from one ruby file >>> which has loaded another ruby file, I can't call any module functions in >>> that other ruby file from the first ruby file. >>> >> >> Well, using those functions worked for me when I loaded the module as an >> .rb file. >> >> Uhm, not sure what I did, but this works for me: >> >> # script2.rb # Notice, no X >> module TestMod >> def TestMod::test() >> print("test") >> end >> end >> >> # > > script1.rbx >> load "script2.rb" # Or require "script2" as suggested by James >> TestMod::test() >> puts # Without this, Netscape replies "Document contained no data." >> >> Looks like perhaps some flushing problem in mod_ruby? I get "test" as a >> result by this on my server. >> I'm on ruby 1.6.7 (2002-03-01) [i586-linux], with mod_ruby-0.9.8 Ah ha! Okay, the culprit seems to be when the module is defined before the load call which loads another file which also uses the module. Here's an example (you can cut and paste these verbatim): TESTSCR.RBX: module TestMod end load "testmod.rb" TestMod::testfunc() TESTMOD.RB: require "cgi" require "PageTemplate" module TestMod @cgi = CGI.new def TestMod::testfunc() @cgi.print("testfunc\r\n") end begin @cgi.print("HTTP/1.1 200 OK\r\n") @cgi.print("Content-Type: text/plain\r\n\r\n") @cgi.print("start\r\n") rescue Exception => e @cgi.out do "An error occurred!<br>" + "Please report the following message to the administrator:<br>" + "<blockquote>#{e.message}<br>\n#{e.backtrace.join('<br>\n')}</blockquote>" end end end Note that this works fine from the Ruby command-line. However, under mod_ruby it hoses. If you comment out the first two lines in testscr.rbx, it works fine. For some reason, having the module already defined when the other file is loaded causes some sort of problem. Not sure why, exactly. Actually, I moved the module definition to right after the load and the same thing happens. What's going on? Why does having the module definition in the first file crash mod_ruby when I try to call that function? Why is command-line Ruby perfectly happy with it? Sean