From bfd0159413ac7941c80166b41856795d93158bb1 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sun, 1 Jun 2014 09:30:40 -0400 Subject: reuse available collection? check instead of macro Reflection has an available method that is used to check if the reflection is a collection. Any :has_many macro is considered a collection and `collection?` should be used instead of `macro == :has_many`. --- activerecord/lib/active_record/associations/association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations/association.rb') diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 89cbb50035..f1c36cd047 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -179,7 +179,7 @@ module ActiveRecord def creation_attributes attributes = {} - if (reflection.has_one? || reflection.macro == :has_many) && !options[:through] + if (reflection.has_one? || reflection.collection?) && !options[:through] attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key] if reflection.options[:as] -- cgit v1.2.3