diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 249eb1775b..806397f83a 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -68,7 +68,7 @@ module ActiveRecord end def foreign_key_present? - through_reflection.belongs_to? && !owner[through_reflection.foreign_key].nil? + through_reflection.belongs_to_or_through? && !owner[through_reflection.foreign_key].nil? end def ensure_mutable diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 9e32b69786..7b53f9c15c 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -504,6 +504,10 @@ module ActiveRecord @association_scope_cache.clear end + def belongs_to_or_through? + belongs_to? + end + def nested? false end @@ -836,6 +840,10 @@ module ActiveRecord source_reflection.join_scopes(table, predicate_builder) + super end + def belongs_to_or_through? + through_reflection.belongs_to_or_through? + end + def has_scope? scope || options[:source_type] || source_reflection.has_scope? || |