MaD wrote:
> and there is always the obvious solution:
> 
> 1000.times do
>   Voucher.create(:attribute1 => 'value1')
> end

In this case, however, the obvious solution is not the best: each call 
to Voucher.create is a separate DB query.  It's far better to create one 
query to insert all the objects; unfortunately, Rails makes this 
somewhat difficult.  You can either use a plugin such as ar-extensions 
or build the SQL yourself.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to