Project

whodunnit

0.0
No commit activity in last 3 years
No release in over 3 years
A simple edit tracking system to keep track of who changed a model.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4.0.0
 Project Readme

Whodunnit

A simple authoring tool to keep track of changes to a model.

Usage

Install the migration adding the 'Edits' table to your database:

    rake whodunnit:install:migrations

Then start to keep track of changes:

create_edit_entry(item, action = :unknown, custom = nil, by = nil)

Where action can be one of the following: a_unkown, a_show, a_create, a_update, or a_destroy The gem assumes you have a current_user method which contains the logged in user (a la Devise), this can be overridden by passing the by option.

I.e. when an update to an article @article has been made:

create_edit_entry @article, :a_update

Or when you need to save additional data, for say, legal reasons:

create_edit_entry @document, :a_update, @document.to_s

After creating entries, you can obtain them by a number of helper methods:

  • created_by <object>, returns the user which initally created the object.
  • last_edit_by <object>, returns the user which made the last Edit entry on the object.
  • last_edit_at <object>, returns the timestamp the last Edit entry was created.
  • total_edits_on <object>, returns the amount of Edit entries on an object.

If the results are empty it will return the translation for not_found (t('not_found')')

##Pull requests Are always welcome :)