Read more

RailsStateMachine 2.2.0 released

Max E.
December 07, 2023Software engineer at makandra GmbH
  • 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:
        class Form
        
          state_machine :first_wizard_stage do
            state :completed
          end
      
          state_machine :second_wizard_stage do
            state :completed
          end
          
        end
      
      would produce the following warning:
        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 and Form::STATE_BAR_COMPLETE
      • instance methods: #foo_completed? and #bar_completed?
  • Fix bug where additional inclusions of RailsStateMachine::Model would reset previous defined state machines
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot
Posted by Max E. to makandra dev (2023-12-07 12:58)