aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_collection.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/association_collection.rb')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 9507822f40..cf1d0ecefc 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -53,9 +53,13 @@ module ActiveRecord
def create(attributes = {})
# Can't use Base.create since the foreign key may be a protected attribute.
- record = build(attributes)
- record.save unless @owner.new_record?
- record
+ if attributes.is_a?(Array)
+ attributes.collect { |attr| create(attr) }
+ else
+ record = build(attributes)
+ record.save unless @owner.new_record?
+ record
+ end
end
# Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and