Hallo,
ich versuche gerade eine has_many through-Assoziation zu testen, aber ich
erhalte eine Fehlermeldung:
1) Error:
test_add_products(InvoiceTest):
ActiveRecord::HasManyThroughCantAssociateNewRecords: Cannot associate new
records through 'Invoice#sales' on '#'. Both records must have an id in order to
create the has_many :through record associating them.
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_through_association.rb:52:in
`<<'
test/unit/invoice_test.rb:16:in `test_add_products'
Ich habe folgende Verknüpfung
invoices => sales <= products
sales ist also die Kreuztabelle.
Mein Test sieht so aus:
require File.dirname(__FILE__) + '/../test_helper'
class InvoiceTest < Test::Unit::TestCase
fixtures :users
fixtures :products
def test_add_products
i = Invoice.create :user => users(:thatsme)
i.products << products(:first_product)
end
end
Habe ich etwas übersehen?
Viele Grüße
Michael Kastner
--
------------------------------
galt.de Web :-) Services
Michael Kastner
Berliner Straße 3
D-65439 Flörsheim
Telefon +49 (0) 6145 / 938 581
Telefax +49 (0) 6145 / 938 582
E-Mail [EMAIL PROTECTED]
Homepage http://www.galt.de
------------------------------
_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/mailman/listinfo/rubyonrails-ug