From: Karla Guzman Date: 2010-03-04T04:08:32+09:00 Subject: Re: hacer un insert en un ciclo Brian Candler wrote: > > I am guessing that what you want to do is this: > > datostotales = {"foo"=>123, "bar"=>456"} > inventario_tem = InventarioTem.new(datostotales) > inventario_tem.save > > OR: > > columna = ["foo", "bar"] > datostotales = [123, 456] > inventario_tem = InventarioTem.new > columna.each_with_index do |col,i| > inventario_tem.send("#{col}=", datostotales[i]) > end > inventario_tem.save > > or you can combine the two like this: > > columna = ["foo", "bar"] > datostotales = [123, 456] > inventario_tem = > InventarioTem.new(Hash[*columna.zip(datostotales).flatten]) > inventario_tem.save Thanks Brian your explanation was very helpful And sorry for not writing in english, I am very distracted -- Posted via http://www.ruby-forum.com/.