StateMachine::Callback.bind_to_object = true
class Vehicle < ActiveRecord::Base
state_machine :initial => :parked do
event :ignite do
transition :parked => :idling
end
end
end
Vehicle.new.ignite!
# NoMethodError:
# undefined method `notify' for #<Vehicle:0x007fc447433768>
Looks like callbacks are mistakenly being called on Vehicle object rather than StateMachine::Machine.
Happens something like this:
Looks like callbacks are mistakenly being called on
Vehicle
object rather thanStateMachine::Machine
.