pluginaweek/state_machine — Issue #143: Validation inside of state block causes error [MongoMapper]
Author: RipTheJacker
Created: 2011-11-22 22:13:04+00:00
State: open

I haven't tested this outside of my app, but here's a snippet of the code:

```ruby
state_machine :status, :initial => :draft do

state :published do
validate :some_validation
end

# ....

event :publish do
transition [:draft] => :published
end
end
```

When I do this, validations run but the record is never marked as invalid if they fail (```valid?``` returns true). When using ```publish!``` I get:

```
StateMachine::InvalidTransition:
Cannot transition status via :publish from :draft
```

Removing the validation make everything work fine.