Honesty

Honesty is a Rails plugin that allows developers to store and track user activities and system events in a human-readable, easily-searchable format.

Installation

Get the gem

Add Honesty to your Gemfile:

gem 'honesty'

Generate the model

Rails 3:

rails g honesty

Rails 2:

script/generate honesty

Migrate:

rake db:migrate

Usage

Use Honesty in your ActiveRecord model:

class Shoe < ActiveRecord::Base
  honesty
end

Add a fact to a model instance:

Parameters:

  • Context - the object being acted on or the entity being tracked.

  • Agent - the actor, so to speak.

  • Action - the action taking place.

If you want to explicitly denote the context, pass all three parameters

shoe = Shoe.create
shoe.fact("Shoe", "Tim Boisvert", "Created Adidas Superstar II")

If you want to short-cut the fact and use the object’s class name as the context, just pass in the agent and the action

shoe = Shoe.create
shoe.fact("Tim Boisvert", "Created Adidas Superstar II")

Get facts

shoe = Shoe.find(1)
facts = shoe.facts.all

Credits

This plugin is heavily influenced by Acts As Taggable. Thanks to Jack Dempsey et al.

Contributors

Tim Boisvert

More

github.com/timboisvert/honesty