Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get rid of create_record as it is not only used in one place

  • Loading branch information...
commit b93d2189c4cf370927b9796e0008034a5268214f 1 parent 7ce7ae0
@jonleighton jonleighton authored
View
15 activerecord/lib/active_record/associations/association_collection.rb
@@ -195,9 +195,13 @@ def create(attrs = {})
if attrs.is_a?(Array)
attrs.collect { |attr| create(attr) }
else
- create_record(attrs) do |record|
- yield(record) if block_given?
- insert_record(record)
+ ensure_owner_is_persisted!
+
+ transaction do
+ build_record(attrs) do |record|
+ yield(record) if block_given?
+ insert_record(record)
+ end
end
end
end
@@ -423,11 +427,6 @@ def insert_record(record, validate = true)
raise NotImplementedError
end
- def create_record(attributes, &block)
- ensure_owner_is_persisted!
- transaction { build_record(attributes, &block) }
- end
-
def build_record(attributes, &block)
attributes = scoped.scope_for_create.merge(attributes)
record = @reflection.build_association(attributes)
Please sign in to comment.
Something went wrong with that request. Please try again.