Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Support HABTM #2

Open
ryanb opened this issue Jul 1, 2009 · 2 comments
Open

Support HABTM #2

ryanb opened this issue Jul 1, 2009 · 2 comments

Comments

@ryanb
Copy link
Owner

ryanb commented Jul 1, 2009

Currently there is no way to populate has_and_belongs_to_many because there is no model set apart for the join table. There should be additional methods one can call on either side of the association to setup the join.

@ipranay
Copy link

ipranay commented Jan 15, 2011

really need this... I thought it might be possible by populating the join table separately... But I can't even figure out how to populate a table with no "id" field.... I get this error when I tried to do that...
Mysql2::Error: Unknown column 'id' in 'field list': SELECT id FROM roles_users ORDER BY id DESC

@JonathanKnight
Copy link

I am populating a join table by joining with one table as seen in your example and then using a random function to generate id's for the other table. It's not perfect but I need a lot of data to test with and this at least fills up the db.
To populate a table with no 'id' field I wrote a rescue block around the last_id_in_database function (factory.rb line 75). The populate then works as expected as the id field is not needed to populate the data. I would much prefer a nicer method though Ryan.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants