No commit activity in last 3 years
Simple log utility for models. Add any number of optional arbitrary details fields, or user_id.
 Development
 Dependencies
 Project Readme

acts_as_loggable¶ ↑

This library adds logging to an ActiveRecord model.

Inspired by acts_as_commentable.

Usage¶ ↑

class Order < ActiveRecord::Base
  acts_as_loggable
  ...
end

1. Simple¶ ↑

o = Order.find(:first)
o.logs << Log.new(:message => "Credit Card Aprroved")
o.logs.first.message # => "Credit Card Aprroved"

2. With some details¶ ↑

o = Order.find(:first)
log = Log.new(:message => "Credit Card Aprroved")
log.details = [["transaction_id","TX1234"],["test",false],["foo","bar"]]
o.logs << log
o.logs.first.message # => "Credit Card Aprroved"
o.logs.first.details.first.label # => "transaction_id"
o.logs.first.details.first.detail # => "TX1234"

3. Adding a grouping type and an Owner¶ ↑

o = Order.find(:first)
o.logs << Log.new(:message => "Credit Card Aprroved", :group => 'card_approval', :user => User.find(:first), :owner => Store.find(:first))
o.logs.find_by_user(current_user)
o.logs.find_by_owner(current_store)
o.logs.find_by_group('card_approval')

Database¶ ↑

script/generate acts_as_loggable_migration
rake db:migrate