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

Raise StrictLoadingViolationError with polymorphic relation violations #45016

Conversation

adrianna-chang-shopify
Copy link
Contributor

@adrianna-chang-shopify adrianna-chang-shopify commented May 4, 2022

Summary

Closes: #44906

Performing strict_loading! on a model with a polymorphic association currently raises an ArgumentError because it attempts to look up the klass for the association, which is not possible. The error message for StrictLoadingViolationError on models with polymorphic relationships should omit the klass for the association.

Copy link
Member

@eileencodes eileencodes left a comment

I realized while reviewing this activerecord/lib/active_record/log_subscriber.rb needs to be updated too since it also defines a warning message and calls klass on the payload. The same message can be used for both.

@adrianna-chang-shopify
Copy link
Contributor Author

@adrianna-chang-shopify adrianna-chang-shopify commented May 4, 2022

That was an oversight on my part, thanks @eileencodes ! ❤️

Performing strict_loading! on a model with a polymorphic association
currently raises an ArgumentError because it attempts to look up the
klass on the polymorphic association, which is not possible. The error
message for StrictLoadingViolationError on models with polymorphic
relationships should omit the klass for the association.
@adrianna-chang-shopify adrianna-chang-shopify force-pushed the ac-fix-strict-loading-polymorphic-associations branch from 66c038d to 71828a4 Compare May 5, 2022
@eileencodes eileencodes merged commit cd2949d into rails:main May 5, 2022
3 of 4 checks passed
eileencodes added a commit that referenced this issue May 5, 2022
…oading-polymorphic-associations

Raise StrictLoadingViolationError with polymorphic relation violations
@eileencodes
Copy link
Member

@eileencodes eileencodes commented May 5, 2022

Backported to 7-0-stable in cd7700b

@adrianna-chang-shopify adrianna-chang-shopify deleted the ac-fix-strict-loading-polymorphic-associations branch May 5, 2022
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.

2 participants