Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add params_with_assocs/2 to ExMachina.Ecto #105

Closed
paulcsmith opened this issue Mar 18, 2016 · 1 comment
Closed

Add params_with_assocs/2 to ExMachina.Ecto #105

paulcsmith opened this issue Mar 18, 2016 · 1 comment
Assignees

Comments

@paulcsmith
Copy link
Contributor

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.
  • It should also strip out the Ecto associations and other Ecto fields. This will work the same as params_for/2 works currently. https://github.com/thoughtbot/ex_machina/blob/f6285d2033933424d78870e70810acae8885e1fb/lib/ex_machina/ecto.ex#L75
  • 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.
@jsteiner
Copy link
Contributor

Done in #124

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

No branches or pull requests

2 participants