Skip to content

Instantly share code, notes, and snippets.

@the-undefined
Created September 2, 2013 20:22
Show Gist options
  • Save the-undefined/6416940 to your computer and use it in GitHub Desktop.
Save the-undefined/6416940 to your computer and use it in GitHub Desktop.
Multiple record attribute hashes handed to an ActiveRecord model create method uses multiple SQL Insert statements, disappointingly.
Item.create(name: 'one record, one query') # One SQL Insert Query
multiple_items = [{ name: 'record one'}, { name: 'record two' }]
Item.create(multiple_items) # Two Consecutive SQL Insert Queries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment