[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

mod_ruby is making me CRAZY

Javier Valencia

2/23/2005

I'm just crazy, i can't understand anything.
I have two modules: Iptstats and Mods

Code for ipstats is large, but works fine ( a normal module )
Code for Mods is (it don't do nothing right now) :

module Mods

public

def Mods.get()
a = Array.new
end

end


and my sample menu.rb cgi is:

require "mods"

Mods.get()


Well, mod_ruby give me the following FUNNY error:

[Tue Feb 22 23:53:23 2005] [error] mod_ruby: error in ruby
[Tue Feb 22 23:53:23 2005] [error] mod_ruby:
/var/www/localhost/htdocs/menu.rb:3: uninitialized constant
#<Module:0x405ceaac>::Mods (NameError)


What the hell is happening here? I don't understand why my other module
works and this one not.
sorry i'm a bit frustrated.


3 Answers

Cameron McBride

2/23/2005 1:29:00 AM

0

Don't really have time to investigate, it's been a while since I toyed
with mod_ruby.

> sorry i'm a bit frustrated.

after you take a deep breath, posting to the mod_ruby ML might be helpful. ;)

http://modruby.net/en/index.rbx/mod_ru...

Cameron


Pit Capitain

2/23/2005 7:32:00 AM

0

Javier Valencia schrieb:
> I'm just crazy, i can't understand anything.
> I have two modules: Iptstats and Mods
>
> Code for ipstats is large, but works fine ( a normal module )
> Code for Mods is (it don't do nothing right now) :
>
> module Mods
>
> public
> def Mods.get()
> a = Array.new
> end
>
> end
>
>
> and my sample menu.rb cgi is:
>
> require "mods"
>
> Mods.get()
>
>
> Well, mod_ruby give me the following FUNNY error:
>
> [Tue Feb 22 23:53:23 2005] [error] mod_ruby: error in ruby
> [Tue Feb 22 23:53:23 2005] [error] mod_ruby:
> /var/www/localhost/htdocs/menu.rb:3: uninitialized constant
> #<Module:0x405ceaac>::Mods (NameError)
>
>
> What the hell is happening here? I don't understand why my other module
> works and this one not.
> sorry i'm a bit frustrated.

I've never used mod_ruby myself, but it seems that menu.rb is run in an
anonymous module, just like

load "menu.rb", true

So it tries to find the constant "Mods" in the namespace of this anonymous
module. If this is the case, try using

::Mods.get()

in menu.rb in order to get at the global namespace.

HTH

Regards,
Pit


Robert Klemme

2/23/2005 4:41:00 PM

0


"Pit Capitain" <pit@capitain.de> schrieb im Newsbeitrag
news:421C31C3.8080008@capitain.de...
> Javier Valencia schrieb:
> > I'm just crazy, i can't understand anything.
> > I have two modules: Iptstats and Mods
> >
> > Code for ipstats is large, but works fine ( a normal module )
> > Code for Mods is (it don't do nothing right now) :
> >
> > module Mods
> >
> > public
> > def Mods.get()
> > a = Array.new
> > end
> >
> > end
> >
> >
> > and my sample menu.rb cgi is:
> >
> > require "mods"
> >
> > Mods.get()
> >
> >
> > Well, mod_ruby give me the following FUNNY error:
> >
> > [Tue Feb 22 23:53:23 2005] [error] mod_ruby: error in ruby
> > [Tue Feb 22 23:53:23 2005] [error] mod_ruby:
> > /var/www/localhost/htdocs/menu.rb:3: uninitialized constant
> > #<Module:0x405ceaac>::Mods (NameError)
> >
> >
> > What the hell is happening here? I don't understand why my other
module
> > works and this one not.
> > sorry i'm a bit frustrated.
>
> I've never used mod_ruby myself, but it seems that menu.rb is run in an
> anonymous module, just like
>
> load "menu.rb", true
>
> So it tries to find the constant "Mods" in the namespace of this
anonymous
> module. If this is the case, try using
>
> ::Mods.get()
>
> in menu.rb in order to get at the global namespace.

Another thing that could possibly go wrong is that the file that's loaded
by "require 'mods'" is a different file and does not contain module Mods.

Regards

robert