Skip to content

Binding callbacks to object breaks ActiveRecord integration #282

@SkyWriter

Description

@SkyWriter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions