Skip to content

Instantly share code, notes, and snippets.

@liorrozen
Created November 5, 2015 12:58
Show Gist options
  • Save liorrozen/6651a6337b833646114e to your computer and use it in GitHub Desktop.
Save liorrozen/6651a6337b833646114e to your computer and use it in GitHub Desktop.
Generate an INSERT sql statement from an existing active record
u.class.arel_table.create_insert.tap { |im| im.insert(u.send(:arel_attributes_with_values_for_create,u.attribute_names)) } .to_sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment