2014-02-10 75 views
0

有没有办法来覆盖rails默认方法触及相关模型的时间戳?覆盖rails activerecord touch方法

例子:

class User 
    belongs_to :employer, touch: true 
end 

我希望覆盖的触摸方法而非触摸雇主的时间戳应该做些别的事情。

回答

1

你应该能够做这样的事

class User 
    ... 
    def touch 

    # your fancy stuff goes here 

    super 
    end 
end