Hola.
quiero hacer un insert a mi base de datos mediante un ciclo
es decir que en el cliclo este la columna y el valor. de los datos
alguien sabe si se puede?
inventario_tem = InventarioTem.new(
while @y < @datostotales.length do
@columna => @datostotales[@y])
@y+=1
end
inventario_tem.save
muchas gracias
···
--
Posted via http://www.ruby-forum.com/.
Hola.
quiero hacer un insert a mi base de datos mediante un ciclo
es decir que en el cliclo este la columna y el valor. de los datos
alguien sabe si se puede?
This doesn't seem very efficient.
Second, could you please speak in english. Even with google translate,
the technical message
is lost.
Andrew McElroy
···
2010/3/1 Karla Guzman <karlaliliana.03@gmail.com>:
inventario_tem = InventarioTem.new(
while @y < @datostotales.length do
@columna => @datostotales\[@y\]\)
@y+=1
end
inventario_tem.save
muchas gracias
--
Posted via http://www.ruby-forum.com/\.
Eso asi mismo no funciona, te daria una alternativa pero sin mas
detalles no cuadra mucho que @columna sea fijo.
Esta es una lista en ingles de todos modos, si no sabes ingles por
favor envia tu consulta a la lista ror-es.
···
2010/3/2 Karla Guzman <karlaliliana.03@gmail.com>:
quiero hacer un insert a mi base de datos mediante un ciclo
es decir que en el cliclo este la columna y el valor. de los datos
alguien sabe si se puede?
inventario_tem = InventarioTem.new(
while @y < @datostotales.length do
@columna => @datostotales\[@y\]\)
@y+=1
end
inventario_tem.save
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/\.
Hola.
quiero hacer un insert a mi base de datos mediante un ciclo
es decir que en el cliclo este la columna y el valor. de los datos
alguien sabe si se puede?
This doesn't seem very efficient.
Second, could you please speak in english. Even with google translate,
the technical message
is lost.
por favor tu habla Inglés.
Andrew McElroy
···
On Mon, Mar 1, 2010 at 5:18 PM, andrew mcelroy <sophrinix@gmail.com> wrote:
2010/3/1 Karla Guzman <karlaliliana.03@gmail.com>:
inventario_tem = InventarioTem.new(
while @y < @datostotales.length do
@columna => @datostotales\[@y\]\)
@y+=1
end
inventario_tem.save
muchas gracias
--
Posted via http://www.ruby-forum.com/\.
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/\.