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)
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.