Can a “touch” be used in Rails's own_to polymorphic relationships?

I expected the following to work:

class Attachment < ActiveRecord::Base
   belongs_to :attachable, :polymorphic => true, :touch => true
end

which I expect related objects to be “affected” when the attachment record is saved or destroyed. This did not work. Any ideas why?

+5
source share
1 answer

Yes, that should work. I used this in several projects (2.3.x and 3.0.x), and it just works.

touch : attachment.attachable.touch, , updated_at. , : touch .

+8

All Articles