Forum: Ruby on Rails Turn Massive Array into new Objects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nik (Guest)
on 2009-05-28 14:54
(Received via mailing list)
Hello,

So I have this massive array 10k+ items in it
b
=>["aaa","aab",...,"aba","abb",..."zza","zzb","zzc",...,"zzz"]

I need to save them in the Bakery model
I tried to do
Bakery.find(1)
=>{:id=>1, :name => "afe"}

b.each do |x|
  Bakery.new do |b|
    b.name = x
  end
end

I know my home computer can't really beat a server grade machine, but
it still took nearly a minute to process. Is there anyway that this
can be faster?

Thanks!
Nik (Guest)
on 2009-05-28 14:55
(Received via mailing list)
Oops, I mean
b.each do |x|
   Bakery.new do |y|
     y.name = x
   end
 end
This topic is locked and can not be replied to.