state_machines icon indicating copy to clipboard operation
state_machines copied to clipboard

Validation with state as constant aren't working

Open disastrous-charly opened this issue 5 years ago • 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 ?

disastrous-charly avatar Oct 08 '19 04:10 disastrous-charly

Try defining the STATE_* constants outside the array.

seuros avatar Oct 08 '19 04:10 seuros