-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
47 lines (34 loc) · 1.24 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
SimpleStateMachineHistory
=========================
I love using AASM (http://github.com/rubyist/aasm/tree/master). However, I sometimes like to keep track of the evolution of my state machines. This is what this plugin does.
First, run the following rake task to add the necessary table in your database.
rake db:migrate:simple_state_machine_history
Just add the following in your model:
state_machine_history
The default column for state is :state. If your state machine is using a different column, you can specify it like this:
state_machine_history :column => :status_column
Example
=======
class TestStateMachine < ActiveRecord::Base
include AASM
aasm_column :state
aasm_initial_state :pending
aasm_state :pending
aasm_state :active
aasm_event :activate do
transitions :from => :pending, :to => :active
end
state_machine_history
end
class AnotherTestStateMachine < ActiveRecord::Base
include AASM
aasm_column :status_column
aasm_initial_state :pending
aasm_state :pending
aasm_state :active
aasm_event :activate do
transitions :from => :pending, :to => :active
end
state_machine_history :column => :status_column
end
Copyright (c) 2009 Adrien (adrien[at]gn2[dot]fr), released under the MIT license