Fixing errors with state_machine when excluding states

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>

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
Arne Hartherz Over 11 years ago