Enable Logging
The Enable Logging plugin extends ActiveRecord? and ActionController? to automatically log all changes to your model. It uses a polymorphic association to store an audit record for any change of any model objects that you wish to have audited.
Installation
- Install via ./script/plugin install http://svn.omdb-beta.org/plugins/enable_logging
- Generate Migration via ./script/generate enable_logging_migration add_log_entries_table
- Activate in ActionController? and/or ActiveRecord? via
class MyController < ApplicationController log_changes_for :my_model, :another_model end class MyModel < ActiveRecord::Base enable_logging end
You need to activate enable_logging in the Model and in the controller, if you want the current user to be set in the LogEntries?. If you just set enable_logging in your model, no LogEntry? will have a user record attached.
Dependencies
Logging the right user via ActionController? depends on the caching of rails. Therefore you need to activate caching in your environment. It is disabled by default in the development-environment. To change that, edit config/environments/development.rb and set:
config.cache_classes = true config.action_controller.perform_caching = true
Tutorials
- Tutorial - Extend the Agile Web Development with Rails Shop Application with Logging.
