Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. record = Post.new(:title => 'Yay', :body => 'This is some insert SQL')
  2.  
  3. # easiest way to achieve this is by calling protected #arel_attributes_values (tested in
  4. # rails 3.2.13). the alternative is to build the entire insert statement using arel >_>
  5. record.class.arel_table.create_insert \
  6. .tap { |im| im.insert(record.send(:arel_attributes_values, false)) } \
  7. .to_sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement