From: Joel VanderWerf Date: 2003-08-22T03:58:42+09:00 Subject: Re: const_missing Hal E. Fulton wrote: > I just tried to use const_missing (which I think is a > neat idea). > > Shouldn't it work at the top level? Am I doing something > wrong? > > def const_missing > "not found" > end > > p FOO > > The above gives an error. I guess #const_missing gets sent to the class, not to the instance, since constants belong to the class. So make it a class method: irb(main):001:0> def Object::const_missing(c); puts "missing: #{c}"; end => nil irb(main):002:0> AAA missing: AAA => nil