From f0b98050296b57d95dbc789f8e52fa82499d151a Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 14 Feb 2011 20:39:51 +0000 Subject: Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [#6376 state:resolved] --- activerecord/lib/active_record/reflection.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record/reflection.rb') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index ceeb0ec39d..0a0e8d650c 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -394,6 +394,10 @@ module ActiveRecord @source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym } end + def association_primary_key + source_reflection.association_primary_key + end + def check_validity! if through_reflection.nil? raise HasManyThroughAssociationNotFoundError.new(active_record.name, self) -- cgit v1.2.3 From 1644663ba7f678d178deab2bf1629dc05626f85b Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 17 Feb 2011 23:55:05 +0000 Subject: Split AssociationProxy into an Association class (and subclasses) which manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more. --- activerecord/lib/active_record/reflection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/reflection.rb') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 0a0e8d650c..4093a1a209 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -313,7 +313,7 @@ module ActiveRecord macro == :belongs_to end - def proxy_class + def association_class case macro when :belongs_to if options[:polymorphic] -- cgit v1.2.3