From 7ca3ab415d409ba39b07ff5a96da06d68098069b Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 23 Jan 2018 04:28:29 +0900 Subject: Fix building has_one through record Fixes #31762. --- activerecord/lib/active_record/associations/through_association.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record/associations/through_association.rb') diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 54673b74f7..5afb0bc068 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -19,6 +19,10 @@ module ActiveRecord end end + def through_association + @through_association ||= owner.association(through_reflection.name) + end + # We merge in these scopes for two reasons: # # 1. To get the default_scope conditions for any of the other reflections in the chain -- cgit v1.2.3