0

I am doing something like this to insert multiple records at the same time in my rails app.

VoteRecord.create(
  [
    { :prospect_id => prospect.id, :state => "OH", :election_type => "GE" },
    { :prospect_id => prospect.id, :state => "OH", :election_type => "PR" }
    ...
   ]  
)

When I check the log i see that the insert query is fired multiple times by sql. Is it possible to do this in a single query?

2 Answers 2

2

You can try active record import for bulk import,checkout wiki and example page.

Sign up to request clarification or add additional context in comments.

Comments

0

I haven't used it myself, but you should check out the activerecord-import project (for Rails 3) github More on this can be found here: wiki

1 Comment

Duplicate! See Amar's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.