我需要在表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)
答案 0 :(得分:1)
Questions.where(id: question_id).update_all(status: status_id.to_i)