I expected the following to work:
class Attachment < ActiveRecord::Base
belongs_to :attachable, :polymorphic => tr开发者_JAVA百科ue, :touch => true
end
which I expect the associated objects to be "touched" when the Attachment record is saved or destroyed. It didn't work. Any ideas why?
Yes this should work. I have used this on several projects (2.3.x and 3.0.x) and it just works.
You may try to call touch manually like this: attachment.attachable.touch, then reload the attachable object and see if its updated_at field has been modified. If so, the :touch option should does that automatically.
精彩评论