The API docs for habtm don't include mention of #build or #create as methods on the association. However, both methods exist in the HasAndBelongsToManyAssociation class. HABTM implements #build, while #create is inherited from AssociationCollection. #build seems to work fine, though there aren't any tests for it. On the other hand, while #create will build and save the associated object, it doesn't create a row in the join table.

I think it's an easy fix to get #create working, at least it looks like it. But since these methods aren't documented I'm not sure what's going on. Were they left out of the docs by accident, or was that intentional because of some subtle problem preventing a solid implementation? Is the broken code there a leftover that was meant to be removed, or an attempt that was meant to be finished later.

If the answer is that #build and #create should be supported in habtm, I can open a ticket and see what I can do about fixing #create and getting some tests written. If the answer is they are leftover garbage, we should probably excise them so people aren't confused by broken behavior.

--
Josh Susser
http://blog.hasmanythrough.com


_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to