`
netfork
  • 浏览: 481130 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Override automatic updated_at in ActiveRecord/Rails

    博客分类:
  • Ruby
阅读更多
http://www.neeraj.name/blog/articles/800-override-automatic-updated_at-in-activerecord-rails

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  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics