# Proper timestamps in callbacks

**URL:** <https://www.ruby-forum.com/t/proper-timestamps-in-callbacks/117799>\
**Category:** Rails\
**Created:** [October 20, 2007, 1:58pm UTC](https://www.ruby-forum.com/t/proper-timestamps-in-callbacks/117799 "2007-10-20T13:58:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leethal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e99b99/32.png) [@leethal](https://www.ruby-forum.com/u/leethal)\
**Post date:** [October 20, 2007, 1:58pm UTC](https://www.ruby-forum.com/t/proper-timestamps-in-callbacks/117799/1 "2007-10-20T13:58:54Z")

</div>

Yay, another Task model:

## the model

class Task \< ActiveRecord::Base

attr\_accessible :lots, :of, :stuff, :but, :not, :finished\_at, :and,  
:finished

before\_save do  
@before\_save.call if @before\_save  
end

def finish  
self.finished = true  
@before\_save = proc { self.finished\_at = Time.now }  
end  
end

## usage

t = Task.find(some\_id)  
t.finish  
t.save

(same code on pastie: [Parked at Loopia](http://pastie.caboo.se/109143))

I’m thinking that going self.finished-at = Time.now directly in the  
finish method will cause finished\_at to be a bit earlier that  
updated\_at. I want it to be the same.

Ideas? The method above is working, but it seems a bit overkill.
