Forum: Ruby on Rails namespaces in subclasses

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F48118fe74b0c7f6fd82a0ee422fa34e?d=identicon&s=25 snacktime (Guest)
on 2007-02-19 00:48
(Received via mailing list)
I have several modules that I store in rails_root/lib and that are
used by my controllers.  I'm having a problem accessing AR objects
from inside a class that is a subclass.  I keep getting a NameError
when trying to do something like Foo.find(), where Foo is an AR

uninitialized constant

For some reason the namespace has changed inside my class instance (an
instance of CreditCardCharge) so that the AR object PaymentAccount is
no longer there.  If I access PaymentAccount from a class instance
that is not a subclass, it works fine.  What am I missing?

Ae97ad0da5c7887be291561eb1720093?d=identicon&s=25 Alex Soto (asoto)
on 2007-02-19 22:59
(Received via mailing list)
Hey there,

Only thing that come's to mind is that the object your trying to
access hasn't been 'require'-ed, hence the 'unitialized constant'
error.  You might want to try the debugger <
ruby-debug> and step into the code to see where the error occurs.
Once you step through the code I'm sure you'll have an ah-ha moment
where the error will make sense.  I hope you find something that will
let you work around the problem.  I haven't tried namespaced models,
so not sure if you'll find a fix.
This topic is locked and can not be replied to.