I am using Ruby on Rails 3.2.2 and I am running the following raw SQL:
sql = "INSERT INTO articles (`title`, `user_id`) VALUES #{inserts.join(", ")}"
ActiveRecord::Base.connection.execute(sql)
However, I would like to use the Ruby on Rails exec_insert method but there isn’t good documentation about that. So, how can I use the exec_insert method so to make the same thing I stated above (maybe using something like Article.connection.exec_insert(...))?
exec_insertis an internal method and probably isn’t what you want here. What you have should be fine.If you’re really set on using it, and need examples, the test suite possibly the best place to find them. One example is here.