【发布时间】:2014-03-12 17:11:28
【问题描述】:
如何在 activerecord 中进行查询:
UPDATE table_name SET column = 'value' WHERE id = 123 RETURNING other_column
我尝试了update_all,但它返回已更改记录的数量,update_atributes 返回真/假,update 返回整个对象。
在 Rails 中它应该是这样的(伪代码):
other_column = TableName.where(:id => 123).update_attributes(:column => 'value').returning(:other_column)
puts other_column
【问题讨论】:
-
请用您实现的代码详细说明您的问题。 (模型、控制器等)
标签: ruby-on-rails postgresql activerecord arel