0

我需要更新表中的“状态”字段,where id == question_id. 我试过这个,但它不工作:

Questions.update_all("status = status_id.to_i", 
               ["id = question_id"])

我有这个错误:

Mysql2::Error: Unknown column 'question_id' in 'where clause': UPDATE `questions` SET status = status_id.to_i WHERE (id = question_id)
4

1 回答 1

1

像这样?

Questions.where(id: question_id).update_all(status: status_id.to_i)

于 2013-04-27T09:10:01.993 回答