In my online store, each order is associated with a shipping address and a billing address (they can be the same, of course). This is my first attempt to model this:
Class Order
belongs_to :billing_address, :class => "Address"
belongs_to :shipping_address, :class => "Address"
This works pretty well, but now the form helpers don't work. I.e., form_for
will only generate fields with names like address[zipcode]
, so I have to manually hack it to get billing_address[zipcode]
and shipping_address[zipcode]
.
I guess I could use single table inheritance to subclass Address
into ShippingAddress
and BillingAddress
, but this seems a bit hacky to me (and contradicts some good answers in http://stackoverflow.com/questions/648463/best-way-to-model-customer-address).