state-machines/state_machines

Validation with state as constant aren't working

Opened this issue · 1 comments

Hi,
Writing this issue because I use your gem and I have one small issue :

My state are constant, like that :
STATES = [ STATE_INTERNAL_DELIVERY = 'internal_delivery', STATE_DELIVERABLES_PENDING_REVIEW = 'deliverables_pending_review', STATE_FINISHING_STEP = 'finishing_step' ].freeze

and I'm trying to do a validation with :
state STATE_FINISHING_STEP, STATE_DELIVERABLES_PENDING_REVIEW, STATE_INTERNAL_DELIVERY do validate :validate_delivery_possible end

Which will run only on the last state.

But if I do this :

state 'deliverables_pending_review', 'internal_delivery', 'finishing_step' do validate :validate_delivery_possible end

It's running as expected.

Do you know why ?

Try defining the STATE_* constants outside the array.