Hello, I have some many-to-many relations, I would like to use in my tests. But I''m not sure what I should put in the fixtures for it? How do I add those relations in the testing environment? Greetings, Gitte Wange
Jens-Christian Fischer
2006-Jan-09 14:29 UTC
[Rails] Using many-to-many relations in tests
> I have some many-to-many relations, I would like to use in my > tests. But I''m not sure what I should put in the fixtures for it? > How do I add those relations in the testing environment?you need to create fixtures for your join table as well: if you have two models (Foo and Bar) and a bar_foos table for the join: bar_foos.yml first: foo_id: 1 bar_id: 1 second: foo_id: 1 bar_id: 2 etc. in your unit tests, load all fixtures: fixtures :foos, :bars, :bar_foos hth jc -- InVisible GmbH, Langgr?tstrasse 172, 8047 Z?rich Phone: +41 44 401 09 30 http://www.invisible.ch http://not.invisible.ch -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2361 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/b296862c/smime-0001.bin