> > Order > belongs_to :customer > belongs_to :billing_address, :class_name => 'Address' > belongs_to :shipping_address, :class_name => 'Address' > ....snip.... > 1) in the OrdersController > > def new > @order = current_user.orders.build( > :billing_address => > current_user.preferred_billing_address, > :shipping_address => > current_user.preferred_shipping_address > ) > #... > end
One thing that popped into my head while reading this is that given the above, if I update my shipping/billing address, any orders I've previously placed will have their addresses updated as well. Which may not be what you want -- since you'd lose the ability to tell where an order was shipped should I do that. So, you might want to add some logic to the Address model that if the address currently being changed is associated with any orders that instead a new address should be created and the old one set to some sort of "archived, but need to keep around as it relates to an order" status. This is similar to needing to store the price of the product in the order itself so that if you later change the price you aren't retroactively changing the order information... -philip -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.

