【发布时间】:2014-02-10 21:24:50
【问题描述】:
有没有办法覆盖涉及相关模型时间戳的rails默认方法?
例子:
class User
belongs_to :employer, touch: true
end
我想重写 touch 方法,而不是触摸雇主的时间戳应该做其他事情。
【问题讨论】:
标签: ruby-on-rails-3 activerecord callback
有没有办法覆盖涉及相关模型时间戳的rails默认方法?
例子:
class User
belongs_to :employer, touch: true
end
我想重写 touch 方法,而不是触摸雇主的时间戳应该做其他事情。
【问题讨论】:
标签: ruby-on-rails-3 activerecord callback
你应该能够做这样的事情
class User
...
def touch
# your fancy stuff goes here
super
end
end
【讨论】: