开发者

insert a value into an integer column without updating it, but adding it's contents

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜