1
0
Fork 0
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:
Aaron Patterson 2011-02-07 16:25:22 -08:00
parent 2b4de6621f
commit 08ef06dbf1
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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