I am wondering if this gem provides a way to keep history of states. I probably can do this by adding a callback to each event but I am wondering what other people think about this approach.
Asked
Active
Viewed 1,458 times
2
-
I am not sure about aasm gem but i have used with state machine. https://github.com/wvanbergen/state_machine-audit_trail this might be helpful. – Vijay Sali Aug 14 '14 at 06:06
-
AASM does not support it and there are currently no plans for it. – alto Aug 15 '14 at 15:46
-
In general, you need to consider that you will create an ever growing table when you start saving state changes... this can lead to huge, hard to migrate tables, and ultimately to id-space exhaustion. A no-SQL store, like DynamoDB, might be a choice here. – Tilo Feb 20 '23 at 15:45
1 Answers
3
I looked at this recently and the two solutions I found were the assm_history gem and paper_trail. Given that I already had paper_trail installed, I ended up going with that.
edit: Per @BKSpurgeon's question below, we ended up adding an after_save
callback on the model, and then created a new row in a new table on every state transition. Prior to that, I added a transition from :any => :any
and did it there.
after_save -> { record_item_transition }, if: :state_changed?

Waynn Lue
- 11,344
- 8
- 51
- 76
-
1
-
Friends don't let friends use Papertrail! Its major flaw is that it stores the diffs for all models in your project in just one table, creates a huge ever-growing table, and its YAML format is hard to query. – Tilo Feb 20 '23 at 15:54