aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-02 15:37:09 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-02 15:37:09 +0000
commita18b3bf5c02657121f1b1451c735d6647f0418e6 (patch)
tree84823a9ecf66f2882f8ea35402507d61bc4c3922 /activerecord/lib
parentce58e5cd069ef1341b8a60be1690b2a912a0b85f (diff)
downloadrails-a18b3bf5c02657121f1b1451c735d6647f0418e6.tar.gz
rails-a18b3bf5c02657121f1b1451c735d6647f0418e6.tar.bz2
rails-a18b3bf5c02657121f1b1451c735d6647f0418e6.zip
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@312 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/acts/touch.rb34
1 files changed, 0 insertions, 34 deletions
diff --git a/activerecord/lib/active_record/acts/touch.rb b/activerecord/lib/active_record/acts/touch.rb
deleted file mode 100644
index baf217542a..0000000000
--- a/activerecord/lib/active_record/acts/touch.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module ActiveRecord
- module Mixins
- # Including this mixins will record when objects of the class are created in a datetime column called "created_at"
- # and when its updated in another datetime column called "updated_at".
- #
- # class Bill < ActiveRecord::Base
- # include ActiveRecord::Mixins::Touch
- # end
- #
- # bill = Bill.create("amount" => 100)
- # bill.created_at # => Time.now at the moment of Bill.create
- # bill.updated_at # => Time.now at the moment of Bill.create
- #
- # bill.update_attribute("amount", 150)
- # bill.created_at # => Time.now at the moment of Bill.create
- # bill.updated_at # => Time.now at the moment of bill.update_attribute
- module Touch
- def self.append_features(base)
- super
-
- base.before_create :touch_on_create
- base.before_update :touch_on_update
- end
-
- def touch_on_create
- self.updated_at = (self.created_at ||= Time.now)
- end
-
- def touch_on_update
- self.updated_at = Time.now
- end
- end
- end
-end \ No newline at end of file