This library adds logging to an ActiveRecord model.
Inspired by acts_as_commentable.
class Order < ActiveRecord::Base acts_as_loggable ... end
o = Order.find(:first) o.logs << Log.new(:message => "Credit Card Aprroved") o.logs.first.message # => "Credit Card Aprroved"
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"
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')
script/generate acts_as_loggable_migration rake db:migrate