-
Added: State machine can now use the
:prefix
-option to avoid name collision if you define multiple state machines on the same model, and use state names more than once- Previously
state_machine
-definitions like this:would produce the following warning:class Form state_machine :first_wizard_stage do state :completed end state_machine :second_wizard_stage do state :completed end end
rails_state_machine-2.1.1/lib/rails_state_machine/state_machine.rb:62: warning: already initialized constant Form::STATE_COMPLETED
- This can now be fixed with the
:prefix
-option:class Form state_machine :first_wizard_stage, prefix: :foo do state :completed end state_machine :second_wizard_stage, prefix: :bar do state :completed end end
- This defines the following:
- constants:
Form::STATE_FOO_COMPLETED
andForm::STATE_BAR_COMPLETE
- instance methods:
#foo_completed?
and#bar_completed?
- constants:
- Previously
- Fix bug where additional inclusions of RailsStateMachine::Model would reset previous defined state machines
Posted by Max E. to makandra dev (2023-12-07 11:58)