Join GitHub today
Validation not running when including multiple states in `state` block #198
I'm including my real state machine from a module (with ActiveSupport::Concern). I'm not sure if that's related to the issue. I'm using ActiveRecord.
This is an example, the real machine has a lot more logic.
state_machine :state, initial: :unpublished do event :publish do transition :unpublished => :waiting_for_moderation, if: :can_moderate? transition :unpublished => :waiting_for_junk, if: :can_junk? end state :waiting_for_moderation, :waiting_for_junk do validate :custom_validation_method end end def custom_validation_method # THIS NEVER GETS EXECUTED AT ALL self.errors.add(:account, "Has not been verified or something.") end
However, when I add two separate
Hey guys -
This is actually documented in the ActiveRecord integration @ http://rdoc.info/github/pluginaweek/state_machine/master/StateMachine/Integrations/ActiveRecord under the "Validations" section. This is due to a constraint in ActiveRecord's validation framework.