Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Log model changes to Cassandra.
Ruby Shell
Branch: master


Audit sits on top of your model objects and watches for changes to your data. When a change occurs, the differences are recorded and stored in Cassandra.


Include Audit::Tracking into your change-sensitive ActiveRecord models. When you make changes to data in those tables, the relevant details will be written to a Cassandra column family.


>> require 'audit'
>> class User < ActiveRecord::Base; include Audit::Tracking; end
>> u = User.create(:name => 'Adam', :city => 'Dallas')
>> u.update_attributes(:city => 'Austin')
>> u.audits
[#<struct Audit::Changeset changes=[#<struct Audit::Change attribute="username", old="akk", new="therealadam">]>, #<struct Audit::Changeset changes=[#<struct Audit::Change attribute="username", old="adam", new="akk">]>, #<struct Audit::Changeset changes=[#<struct Audit::Change attribute="age", old=30, new=31>]>]


Audit is tested against ActiveRecord 3.0, Ruby 1.8.7 and Ruby 1.9.2.


For Cassandra 0.7, you can set up the schema with cassandra-cli like so:

/* Create a new keyspace */
create keyspace Audit with replication_factor = 1

/* Switch to the new keyspace */
use Audit

/* Create new column families */
create column family Audits with column_type = 'Standard' and comparator = 'TimeUUIDType' and rows_cached = 10000

For Cassandra 0.6, add the following to storage-conf.xml:

<Keyspace Name="Audit">
    <ColumnFamily CompareWith="TimeUUIDType" Name="Audits" />


Set up RVM:

$ rvm install ree-1.8.7-2010.01
$ rvm use ree-1.8.7-2010.01
$ rvm gemset create audit
$ rvm gemset use audit
$ gem install bundler
$ bundle install
$ rvm install 1.9.2
$ rvm use 1.9.2
$ rvm gemset create audit
$ rvm gemset use audit
$ gem install bundler
$ bundle install

Run the test suite with all supported runtimes:

$ rvm 1.9.2@audit,ree-1.8.7-2010.01@audit rake test


  • Ignore changes on some attributes
  • Add more AR callbacks (delete, ?)
  • Generate bucket names for namespaced models


Copyright 2010 Adam Keys <>

Audit is MIT licensed. Enjoy!

Something went wrong with that request. Please try again.