Namespaces in subclasses

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
object.

uninitialized constant
OpenTransact::Gateway::Request::CreditCardCharge::PaymentAccount
(NameError)

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?

Chris

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 <http://www.datanoise.com/
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.