From af2c427c390b87ea20986f1e82b498068800d775 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 29 Feb 2016 14:35:19 -0700 Subject: Respect through association scopes when used with polymorphic When the `source_type` option is passed to a has_many through, the resulting `Reflection` will be an instance of `PolymorphicReflection` and not `ThroughReflection`, meaning that it will ignore the scopes that it needs to apply from the through reflections. This adds an additional delegation call to remedy this. I've been finding the reflection code completely impenetrable lately, it could use some major love. Fixes #22726 --- activerecord/lib/active_record/reflection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 956fe7c51e..43f573f193 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -995,7 +995,7 @@ module ActiveRecord end def constraints - [source_type_info] + @reflection.constraints + [source_type_info] end def source_type_info -- cgit v1.2.3