Sha256: c05ce6883b583cca4f003f65ec2196a1ed94468088cffa672d5d1e12c48a2918
Contents?: true
Size: 673 Bytes
Versions: 23
Compression:
Stored size: 673 Bytes
Contents
require 'active_support/time' module CouchPotato module MagicTimestamps #:nodoc: def self.included(base) base.instance_eval do property :created_at, :type => Time property :updated_at, :type => Time before_create lambda {|model| model.created_at ||= (Time.zone || Time).now @changed_attributes.delete 'created_at' model.updated_at ||= (Time.zone || Time).now @changed_attributes.delete 'updated_at' } before_update lambda {|model| model.updated_at = (Time.zone || Time).now @changed_attributes.delete 'updated_at' } end end end end
Version data entries
23 entries across 23 versions & 2 rubygems