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

Fix build multiple records on association relation to not lose scope values #41342

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Feb 5, 2021

I've realized in #41102, even in main branch build multiple records in
a scoping will lose scope values.

Call scoping for each record to fix the losing scope values.

…e values

I've realized in rails#41102, even in main branch `build` multiple records in
a `scoping` will lose scope values.

Call `scoping` for each record to fix the losing scope values.
@kamipo kamipo merged commit 0f43f55 into rails:main Feb 5, 2021
@kamipo kamipo deleted the fix_build_on_association_relation branch February 5, 2021 09:59
kamipo added a commit that referenced this pull request Feb 5, 2021
Fix `build` multiple records on association relation to not lose scope values
kamipo added a commit to kamipo/rails that referenced this pull request Feb 8, 2021
Follow up to rails#41342.

The reason why the problem of rails#41342 occurred is that unlike `create`,
`build` did not support the creation of multiple records, so it did not
address the problem.

It is weird that `post.commnets.where(foo: "bar").build([obj1, obj2])`
is allowed but `Comment.where(foo: "bar").build([obj1, obj2])` is not
allowed.

To avoid the confusion, it allows `build` multiple records even on non
association relation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant