Ruby on rails 使用现有值添加值rails更新
我有一个Ruby on rails 使用现有值添加值rails更新,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我有一个price列,其值为10(可能不同),我需要向现有值10添加值5(可能不同),这是在rails中更新此值的好方法 我使用以下rails查询按客户id查找 customer\u id=25 return\u update=return.find\u by customer\u id:customer\u id您可以使用多种方法更新值: 经验证: refund_update.increment('price', 5) refund_update.increment!('price',5)
price
列,其值为10
(可能不同),我需要向现有值10
添加值5
(可能不同),这是在rails中更新此值的好方法
我使用以下rails查询按客户id查找
customer\u id=25
return\u update=return.find\u by customer\u id:customer\u id
您可以使用多种方法更新值:
经验证:
refund_update.increment('price', 5)
refund_update.increment!('price',5)
或
未经验证:
refund_update.increment('price', 5)
refund_update.increment!('price',5)
或