From 796d8599f384c7da41318695028d60e62738beb0 Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Tue, 31 Jan 2017 17:12:19 -0500 Subject: Fix collection_singular_ids= bug When the association's primary key is manually set as a symbol and called with an array of strings, CollectionAssociation#ids_writer fails to cast the ids to integers. This is because AssociationReflection#association_primary_key_type and ThroughReflection#association_primary_key_type return the incorrect type, since ModelSchema.type_for_attribute only accepts a string. The result is an ActiveRecord::RecordNotFound error. --- activerecord/lib/active_record/reflection.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 81ec4924b0..61a2279292 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -421,7 +421,7 @@ module ActiveRecord end def association_primary_key_type - klass.type_for_attribute(association_primary_key) + klass.type_for_attribute(association_primary_key.to_s) end def active_record_primary_key @@ -835,7 +835,7 @@ module ActiveRecord end def association_primary_key_type - klass.type_for_attribute(association_primary_key) + klass.type_for_attribute(association_primary_key.to_s) end # Gets an array of possible :through source reflection names in both singular and plural form. -- cgit v1.2.3