允许您在块的持续时间内选择性地禁用对touch的调用。
touch
ActiveRecord::Base.no_touching do Project.first.touch # does nothing Message.first.touch # does nothing end Project.no_touching do Project.first.touch # does nothing Message.first.touch # works, but does not touch the associated project end
来源: 显示 | 在GitHub上
# File activerecord/lib/active_record/no_touching.rb, line 23 def no_touching(&block) NoTouching.apply_to(self, &block) end