更新updated_at时间而不更改任何内容

时间:2014-08-13 19:41:58

标签: ruby-on-rails ruby-on-rails-4

我有什么方法可以触摸模型,导致updated_at字段更新到当前时间而不实际更改其他字段中的任何内容?

1 个答案:

答案 0 :(得分:25)

您可以使用touch

model.touch

model.touch(:updated_at) #or anyother timestamp attribute

文档here