Skip to content

Simple log utility for models. Add any number of optional arbitrary details fields, or user_id.

License

Notifications You must be signed in to change notification settings

darcy/acts_as_loggable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple log utility for models. Add any number of optional arbitrary details fields, or user_id.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages