Skip to content
  • eileencodes's avatar
    46862583
    Fix regression in inverse_of on through associations · 46862583
    eileencodes authored
    `inverse_of` on through associations was accidently removed/caused to
    stop working in commit f8d2899d which was part of a refactoring on
    `ThroughReflection`.
    
    To fix we moved `inverse_of` and `check_validity_of_inverse!` to the
    `AbstractReflection` so it's available to the `ThroughReflection`
    without having to dup any methods. We then need to delegate `inverse_name`
    method in `ThroughReflection`. `inverse_name` can't be moved to
    `AbstractReflection` without moving methods that set the instance
    variable `@automatic_inverse_of`.
    
    This adds a test that ensures that `inverse_of` on a `ThroughReflection`
    returns the correct class name, and the correct record for the inverse
    relationship.
    
    Fixes #21692, backport of ee824c88.
    
    Conflicts:
    	activerecord/lib/active_record/reflection.rb
    	activerecord/test/schema/schema.rb
    46862583
    Fix regression in inverse_of on through associations
    eileencodes authored
    `inverse_of` on through associations was accidently removed/caused to
    stop working in commit f8d2899d which was part of a refactoring on
    `ThroughReflection`.
    
    To fix we moved `inverse_of` and `check_validity_of_inverse!` to the
    `AbstractReflection` so it's available to the `ThroughReflection`
    without having to dup any methods. We then need to delegate `inverse_name`
    method in `ThroughReflection`. `inverse_name` can't be moved to
    `AbstractReflection` without moving methods that set the instance
    variable `@automatic_inverse_of`.
    
    This adds a test that ensures that `inverse_of` on a `ThroughReflection`
    returns the correct class name, and the correct record for the inverse
    relationship.
    
    Fixes #21692, backport of ee824c88.
    
    Conflicts:
    	activerecord/lib/active_record/reflection.rb
    	activerecord/test/schema/schema.rb
Loading