Module: Toy::Timestamps::ClassMethods
- Defined in:
- lib/toy/timestamps.rb
Instance Method Summary collapse
Instance Method Details
#timestamps ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/toy/timestamps.rb', line 8 def attribute(:created_at, Time) attribute(:updated_at, Time) before_create do |record| now = Time.now record.created_at = now unless created_at? record.updated_at = now end before_update do |record| record.updated_at = Time.now end end |