Module: Ampere::Timestamps
- Defined in:
- lib/ampere/timestamps.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ampere/timestamps.rb', line 3 def self.included(base) base.class_eval do field :created_at field :updated_at define_model_callbacks :create, :update, :save before_create do @updated_at = Time.now if @created_at.nil? then @created_at = Time.now end end before_save do @updated_at = Time.now end end end |