chendo / acts_as_audited forked from collectiveidea/acts_as_audited

This URL has Read+Write access

chendo (author)
Wed Jul 02 19:27:35 -0700 2008
commit  d1236b1e8a8a6a4b81870cddd1f82f963c1bf7c7
tree    f8e8bcbadddbd6ab00b5e1d33a70f51488500064
parent  3ed50ff0884c0c97aa0e0fbd263b2a8c9e7b9cf0
name age message
file .gitignore Loading commit data...
file CHANGELOG
file README
file Rakefile
directory generators/
file init.rb Sat May 17 21:56:58 -0700 2008 refactoring to make compatible with dirty track... [brandon]
directory lib/
directory tasks/ Thu Jul 20 09:41:01 -0700 2006 initial import of acts_as_audited plugin git-s... [brandon]
file test.txt Fri Mar 21 11:58:26 -0700 2008 testing post commit again [brandon]
directory test/
README
= acts_as_audited

acts_as_audited is an ActiveRecord extension that logs all changes to your models in an audits table.

== Installation

* Install the plugin into your rails app 
  If you are using Rails 2.1:

    script/plugin install git://github.com/collectiveidea/acts_as_audited.git
  
  For versions prior to 2.1:

    git clone git://github.com/collectiveidea/acts_as_audited.git vendor/plugins/acts_as_audited

* Generate the migration
    script/generate audited_migration add_audits_table
    rake db:migrate

== Auditing in Rails

If you're using acts_as_audited within Rails, you can simply declare which models should be audited.  acts_as_audited 
can also automatically record the user that made the change if your controller has a <tt>current_user</tt> method.

  class ApplicationController < ActionController::Base
    audit User, List, Item
  protected
    def current_user
      @user ||= User.find(session[:user])
    end
  end
  
== Customizing

To get auditing outside of Rails, or to customize which fields are audited within Rails, you can explicitly declare 
<tt>acts_as_audited</tt> on your models:

    class User < ActiveRecord::Base
      acts_as_audited :except => [:password, :mistress]
    end

See http://opensoul.org/2006/07/21/acts_as_audited for more information.

== Caveats

Auditing with user support depends on Rails' caching mechanisms, therefore auditing isn't enabled during development 
mode. To test that auditing is working, start up your app in production mode, or change the following options in 
config/environments/environment.rb: 

  config.cache_classes = true
  config.action_controller.perform_caching = true

=== ActiveScaffold

Many users have also reported problems with acts_as_audited and ActiveScaffold, which appears to be caused by a 
limitation in ActiveScaffold not supporting polymorphic associations. To get it to work with ActiveScaffold:

  class ApplicationController < ActionController::Base
    audit MyModel, :only => [:create, :update, :destroy]
  end

== Upgrading

To upgrade from an older version, add a migration with:

  # to version 0.3
  add_column :audits, :user_type, :string
  add_column :audits, :username, :string

  # to version 0.4
  add_column :audits, :version, :integer, :default => 0