Module | StateMachine::Integrations::ActiveRecord::Observer |
In: |
lib/state_machine/integrations/active_record/observer.rb
|
Adds support for invoking callbacks on ActiveRecord observers with more than one argument (e.g. the record and the state transition). By default, ActiveRecord only supports passing the record into the callbacks.
For example:
class VehicleObserver < ActiveRecord::Observer # The default behavior: only pass in the record def after_save(vehicle) end # Custom behavior: allow the transition to be passed in as well def after_transition(vehicle, transition) Audit.log(vehicle, transition) end end