Created
June 6, 2013 03:10
-
-
Save lankz/5719044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record = Post.new(:title => 'Yay', :body => 'This is some insert SQL') | |
# easiest way to achieve this is by calling protected #arel_attributes_values (tested in | |
# rails 3.2.13). the alternative is to build the entire insert statement using arel >_> | |
record.class.arel_table.create_insert \ | |
.tap { |im| im.insert(record.send(:arel_attributes_values, false)) } \ | |
.to_sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, and: Or for Rails 4