1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Merge pull request #175 from danlo/master

Added a section for transitions
This commit is contained in:
Thorsten Böttger 2014-10-12 15:19:24 +02:00
commit 5b77559ef3

View file

@ -248,6 +248,38 @@ If you want to provide guards for all transitions within an event, you can use e
end
```
### Transitions
In the event of having multiple transitions for an event, the first transition that successfully completes will stop other transitions in the same event from being processed.
```ruby
require 'aasm'
class Job
include AASM
aasm do
state :stage1, :initial => true
state :stage2
state :stage3
state :completed
event :stage1_completed do
transitions from: :stage1, to: :stage3, guard: :stage2_completed?
transitions from: :stage1, to: :stage2
end
end
def stage2_completed?
true
end
end
job = Job.new
job.stage1_completed
job.aasm.current_state # stage3
```
### ActiveRecord
AASM comes with support for ActiveRecord and allows automatical persisting of the object's