我有兩個模型是這樣的:保存模型時,可以暫時禁用belongs_to關聯的觸摸嗎?
class Topic < ActiveRecord::Base
has_many :replies
end
class Reply < ActiveRecord::Base
belongs_to :topic, touch: true
end
當我保存reply.save!
,touch
在主題回覆將被調用,話題updated_at
將更新爲當前時間。
但有時我不想在創建答覆時自動更改updated_at
。那麼,如何在我保存回覆時禁用touch
?
請參閱此。 http://stackoverflow.com/questions/16221586/skipping-touch-associations-when-saving-an-activerecord-object – bhugo313 2014-10-18 23:15:59