ActiveRecord::Base.connection.execute "UPDATE ventas SET costo_de_compra = #{@nuevo_costo} WHERE id = #{@vid};"
but this updates that column valu开发者_StackOverflowe every time it's recursed, what i want is just to insert that value to the already stablished values in that column... in proper instance i want to add the values to an integer column.
Thanks in advance
I don't know Rails, but I guess something like this:
ActiveRecord::Base.connection.execute _
"UPDATE ventas SET costo_de_compra = costo_de_compra + #{@nuevo_costo} _
WHERE id = #{@vid};"
EDIT: oh, it's an integer column. Updated.
If I understand your question right, you are trying to add to the existing value of an integer column. If you are following rails conventions, you should be able to do something like this:
@venta = Venta.find(@vid)
@venta.costo_de_compra += @nuevo_costo
@venta.save
精彩评论