From: Kent Dahl Date: 2002-06-06T05:41:40+09:00 Subject: Re: mod_ruby and module space Sean O'Dell wrote: > 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. Hmm. But if I move the empty module definition into a third .rb file and require that separately, all appears well again. > 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? Does it really crash? Or do you mean merely it doesn't work? I haven't had Apache die on me yet, or any such thing... I have an idea what is going on, but I'm going to investigate a bit more, just in case I'm sticking my foot in my mouth. But for now, I'm getting /home/httpd/html/ruby/test/testscr.rbx:10: undefined method `testfunc' for #::TestMod (NameError) and the nameless module before TestMod makes me think that mod_ruby is wrapping the loaded code, to avoid it cluttering the namespace of other mod_ruby programs? And this might confuse you (and Ruby) with regards to just which TestMod you are accessing. But big foot in mouth disclaimer as I haven't found a good way to test this yet, nor couldn't find anything in the mod_ruby sources at first glance... -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 4. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)