Turn Massive Array into new Objects


#1

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!


#2

Oops, I mean
b.each do |x|
Bakery.new do |y|
y.name = x
end
end