From: Brian Candler Date: 2010-03-02T21:26:18+09:00 Subject: Re: hacer un insert en un ciclo Karla Guzman wrote: > inventario_tem = InventarioTem.new( > while @y < @datostotales.length do > > @columna => @datostotales[@y]) > > @y+=1 > end > inventario_tem.save 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 -- Posted via http://www.ruby-forum.com/.