I''m trying to understand how to use the has_many :through construct.
I have two tables: customers and vendors associated through
"assignments"
table.
Class Customer
has_many :assignments
has_ many :vendors, :through => :assignments
. . . # other fields
end
Class Vendor
has_many :assignments
has_many :customers, :through => :assignments
. . . # other fields
end
Class Assignment
belongs_to :customer
belongs_to :vendor
. . . # other fields
end
How do I build assignments? By that, I mean assign a vendor to a customer?
I''m thinking that I should be able to do this:
v = Vendor.find(1)
c = Customer.find(1)
v.customers << c
but, that doesn''t work. Would someone help me with the correct syntax?
--
Best Regards,
-Larry
"Work, work, work...there is no satisfactory alternative."
--- E.Taft Benson
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060813/a3deb3ff/attachment-0001.html