Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple log utility for models. Add any number of optional arbitrary details fields, or user_id.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators/acts_as_loggable_migration
lib
.gitignore
MIT-LICENSE
README.rdoc
init.rb

README.rdoc

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
Something went wrong with that request. Please try again.