Override auttic udated uat in Active Record/Rails
835 ワード
http://www.neeraj.name/blog/articles/800-override-automatic-updated_t-i-n-activerecord-rals
module ActiveRecord
class Base
def update_record_without_timestamping
class << self
alias_method :orig_record_timestamps, :record_timestamps
def record_timestamps; false; end
end
yield if block_given?
class << self
remove_method :record_timestamps
alias_method :record_timestamps, :orig_record_timestamps
end
end
end
end