On Sat, Nov 21, 2009 at 8:12 PM, Philip Hallstrom <[email protected]> wrote:
>>
>> 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.

No they won't.

When the order is saved, then it will have a shipping_address_id and
billing_address_id set to either the values intialized by the
controller in the new method (which is used as a template for the
values posted back to the create method by the form) or whatever the
user changed it to on the order form.

If the user changes his preferences later, it won't affect existing orders.

I think you might be better off just to write some code and test it
and see what happens, rather than continuing with what seem to be
gedanken experiments.


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

--

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


Reply via email to