W3cubDocs

/Ruby on Rails 4.2

module ActiveRecord::NoTouching::ClassMethods

Public Instance Methods

no_touching(&block) Show source

Lets you selectively disable calls to `touch` for the duration of a block.

Examples

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
# File activerecord/lib/active_record/no_touching.rb, line 21
def no_touching(&block)
  NoTouching.apply_to(self, &block)
end

© 2004–2017 David Heinemeier Hansson
Licensed under the MIT License.