提交 08ef06db 编写于 作者: A Aaron Patterson

just return the record from insert_record, use truthiness for comparisons

上级 2b4de662
......@@ -26,14 +26,14 @@ def size
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 @@ def save_collection_association(reflection)
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 @@ def save_collection_association(reflection)
saved = record.save(:validate => false)
end
raise ActiveRecord::Rollback if saved == false
raise ActiveRecord::Rollback unless saved
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册