Merge pull request #51442 from rosa/skip-deprecation-warning-for-invalid-reflections

Emit deprecation warning about inverse_of inference only for valid reflections
This commit is contained in:
Rafael Mendonça França 2024-05-17 16:38:06 -04:00 committed by GitHub
commit d0ce794e2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -760,7 +760,7 @@ def automatic_inverse_of
plural_inverse_name = ActiveSupport::Inflector.pluralize(inverse_name)
reflection = klass._reflect_on_association(plural_inverse_name)
if reflection && !active_record.automatically_invert_plural_associations
if valid_inverse_reflection?(reflection) && !active_record.automatically_invert_plural_associations
ActiveRecord.deprecator.warn(
"The `#{active_record.name}##{name}` inverse association could have been automatically" \
" inferred as `#{klass.name}##{plural_inverse_name}` but wasn't because `automatically_invert_plural_associations`" \