Forum: Ruby on Rails uninitialized constant error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tony H. (Guest)
on 2006-01-19 09:52
I have a single table inheritance model for some classes
Payment < ActiveRecord::Base
CreditCardPayment < Payment
ECheckPayment < Payment
ManualPayment < Payment

they all get persisted to the payments table

I'm getting an error: 'uninitialized constant Payment' when trying to
create a new instance of any of these classes. At one point in my
process I store the payment in a session variable, but I've it seems
random as to when this happens: before or after that gets set. I even
tried explicitly requiring the payment class in the sub classes, and
still get the error.

I'm using Webrick on ruby 1.8.3 installed on cygwin on a Windows XP
machine.

Any ideas what's going on? As I'm sure we all are, I'm under a time
crunch, and this is an unexpected error. Please help!
Alex Y. (Guest)
on 2006-01-19 11:51
(Received via mailing list)
Tony Hillerson wrote:
> I have a single table inheritance model for some classes
> Payment < ActiveRecord::Base
> CreditCardPayment < Payment
> ECheckPayment < Payment
> ManualPayment < Payment
>
> they all get persisted to the payments table
Do you have a 'type' column in the payments table?  I presume you do,
but it's always best to check...

> I'm using Webrick on ruby 1.8.3 installed on cygwin on a Windows XP
> machine.
That could be a source of problems:  the Rails site specifically
recommends against 1.8.3.

I'd ditch cygwin ruby and use the one-click installer if I were you,
just to get rid of the question mark.  It's working fine for me.
This topic is locked and can not be replied to.