Read more

Fixing errors with state_machine when excluding states

Arne Hartherz
October 15, 2012Software engineer at makandra GmbH

This is for you if you get the following strange error from the state_machine gem Show archive.org snapshot :

undefined method `-' for #<StateMachine::BlacklistMatcher:0x124769b0>
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

You probably did something like this in your state_machine ... do block:

def self.final_states
  [ :foo, :bar ]
end

transition (all - machine.final_states - [:baz]) => :target_state

Instead, define the source states like this:

def self.final_states
  [ :foo, :bar ]
end

transition (all - (machine.final_states | [:baz])) => :target_state
Posted by Arne Hartherz to makandra dev (2012-10-15 10:54)