No commit activity in last 3 years
No release in over 3 years
Audits for the state_machine gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.2.1
~> 2.4.0
~> 1.3.3

Runtime

>= 3.0.0
 Project Readme

StateMachineAudits

This gem is meant to be used in conjunction with the state_machine gem in a Rails3 project. It will hook into before_save and track any state changes that happen in its own database table.

To that end, you need a migration that looks something like this:

class CreateStateMachineStateAudits < ActiveRecord::Migration
  def self.up
    create_table :state_machine_state_audits do |t|
      t.string :state_machine_auditable_type
      t.integer :state_machine_auditable_id
      t.string :state_field
      t.string :state
      t.timestamps
    end
  end

  def self.down
    drop_table :state_machine_state_audits
  end
end

After that, you just include the module in your class that uses state_machine like so:

class SomeClass < ActiveRecord::Base
  include StateMachineAudits
end

That's it, you're done. Now it will keep a record of each state transition.