pluginaweek / state_machine

Adds support for creating state machines for attributes on any Ruby class
http://www.pluginaweek.org
MIT License
3.74k stars 507 forks source link

Binding callbacks to object breaks ActiveRecord integration #282

Open SkyWriter opened 10 years ago

SkyWriter commented 10 years ago

Happens something like this:

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.

tyre commented 10 years ago

:+1: