Jeffrey Moss
2005-Apr-22 22:43 UTC
Problem with multiple associations referencing the same table
I have an order object that starts out like this: class Order < ActiveRecord::Base belongs_to :billing_address, :class_name => ''Address'', :foreign_key => ''billing_address_id'' belongs_to :service_address, :class_name => ''Address'', :foreign_key => ''service_address_id'' belongs_to :shipping_address, :class_name => ''Address'', :foreign_key => ''shipping_address_id'' When I attempt to use the same Address object for 2 or more of these values, the order object gets the attribute set ok, but when I save it only one of the associations is linked, the first one I set. Is this expected behavior? I have tried many different things and I can never get more than 1 association to save in the orders table, I can get different associations to save but never more than one. -Jeff