I’m using AASM to manage states and just wanted to have some columns that kept track of the times the state were changed, but the callbacks don’t seem to be working. The problems, of course, could be with my methods, I’m just not sure.
aasm_state :active, :after => :activate
aasm_state :inactive
aasm_state :deactivated, :after => :deactivate
aasm_event :active do
transitions :to => :active, :from => [:inactive]
transitions :to => :active, :from => [:deactivated]
end
aasm_event :deactivated do
transitions :to => :deactivated, :from => [:active]
end
def activate
activated_at = Time.now
end
def deactivate
deactivated_at = Time.now
end
when using aasm, you dont just call your activate / deactivate function on your model.
you also need to save the model, so when you do
object.activate, after that also doobject.save(at least that is how it was in the last version i used)transitions seem to be written ok, so i dont think those are the problem