This one has bitten me before too.
There are a couple of ways around it, but the one that I use is this:
Create separate billing_address.rb and shipping_address.rb files in
your models directory instead of including them in your address.rb
file.
On Jul 30, 2:07 pm, Josh
<jjkie...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> when trying to figure out STI i''ve hit a problem..
>
> in my address.rb file i have the following:
>
> class Address < ActiveRecord::Base
>
> validates_presence_of :name, :address_1, :city, :state, :zip
>
> belongs_to :order
> end
>
> class BillingAddress < Address
> end
>
> class ShippingAddress < Address
> end
>
> now when in the console and i try to access BillingAddress, i get
> "uninitialized constant" errors, but if i access Address first,
> BillingAddress loads up fine. i thought all of the models were loaded
> when the app was started, so why is it not recognizing my sub classes?
> my other question is what i need to put in my code to make sure that i
> can access the subclass even if i haven''t accessed the parent one
> first? i''m guess i need to load it somewhere but i don''t
know where or
> what syntax to use.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---