You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the issue by @geofflane in #104. I would love help on this if someone has time, if not I hope to tackle this in a few weeks.
Add params_with_assocs/2 to ExMachina.Ecto
Should accept the same arguments as ExMachina.Ecto.params_for/2
It will insert belongs_to relationships from the factory, but not insert the factory itself. e.g. if you call params_with_assocs(:comment) it should insert the comment's belongs_to associations, but not the comment itself.
After inserting the associations it should set the association's id. So if a Comment belongs_to a Post, params_with_assocs(:comment) would insert the post and use the post's primary key and put on on the comment.
You should be able to override associations, e.g. params_with_assocs(:comment, post: build(:post)). If the post is built then it will insert it and set the appropriate foreign key. If the association has already been inserted it will not try to insert it again, and will set the appropriate foreign key.
The text was updated successfully, but these errors were encountered:
Based on the issue by @geofflane in #104. I would love help on this if someone has time, if not I hope to tackle this in a few weeks.
params_with_assocs/2
to ExMachina.EctoExMachina.Ecto.params_for/2
belongs_to
relationships from the factory, but not insert the factory itself. e.g. if you callparams_with_assocs(:comment)
it should insert the comment's belongs_to associations, but not the comment itself.Comment
belongs_to aPost
,params_with_assocs(:comment)
would insert the post and use the post's primary key and put on on the comment.params_for/2
works currently. https://github.com/thoughtbot/ex_machina/blob/f6285d2033933424d78870e70810acae8885e1fb/lib/ex_machina/ecto.ex#L75params_with_assocs(:comment, post: build(:post))
. If the post is built then it will insert it and set the appropriate foreign key. If the association has already been inserted it will not try to insert it again, and will set the appropriate foreign key.The text was updated successfully, but these errors were encountered: