I need to insert a array of emails as different records into my contacts table. How can this be done.
Eg: @email = ["[email protected]", "[email protected]", "[email protected]", ... ]
I dont want to use.
@email.each do |email|
@contact = Contact.new
@contact.email = email
@contact.save
end
This cause n insert quires. I just need a single insert query to insert these values. How can this be done in rails 3.0.9 (and ideally MySQL). Please help
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…