mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
just return the record from insert_record, use truthiness for comparisons
This commit is contained in:
parent
2b4de6621f
commit
08ef06dbf1
2 changed files with 5 additions and 3 deletions
|
@ -26,14 +26,14 @@ module ActiveRecord
|
|||
|
||||
def insert_record(record, force = true, validate = true)
|
||||
if record.new_record?
|
||||
return false unless save_record(record, force, validate)
|
||||
return unless save_record(record, force, validate)
|
||||
end
|
||||
|
||||
through_association = @owner.send(@reflection.through_reflection.name)
|
||||
through_association.create!(construct_join_attributes(record))
|
||||
|
||||
update_counter(1)
|
||||
true
|
||||
record
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -306,6 +306,8 @@ module ActiveRecord
|
|||
records.each do |record|
|
||||
next if record.destroyed?
|
||||
|
||||
saved = true
|
||||
|
||||
if autosave && record.marked_for_destruction?
|
||||
association.destroy(record)
|
||||
elsif autosave != false && (@new_record_before_save || record.new_record?)
|
||||
|
@ -318,7 +320,7 @@ module ActiveRecord
|
|||
saved = record.save(:validate => false)
|
||||
end
|
||||
|
||||
raise ActiveRecord::Rollback if saved == false
|
||||
raise ActiveRecord::Rollback unless saved
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue