方法
实例公有方法
no_touching(&block) 链接
允许您选择性地禁用对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