This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit e5bdb7faea7185f06a2e242a2924b01b279dd4be
tree 569599e3c0759b53c3066e6e0fa1d7792bde7bdb
parent 9746cf31222b999135b7f260a229d510d49793f5
tree 569599e3c0759b53c3066e6e0fa1d7792bde7bdb
parent 9746cf31222b999135b7f260a229d510d49793f5
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sat Apr 19 11:20:36 -0700 2008 | [darcy] |
| |
README | Wed Apr 23 08:16:23 -0700 2008 | [darcy] |
| |
init.rb | Sat Apr 19 11:20:36 -0700 2008 | [darcy] |
| |
lib/ | Sat Apr 19 11:20:36 -0700 2008 | [darcy] |
README
== acts_as_loggable
This library adds simple logging to an ActiveRecord model.
Heavily inspired by acts_as_commentable. Did I say heavily?
== Usage
class Order < ActiveRecord::Base
acts_as_loggable
...
end
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"
Details are optional, also, pass a user_id to log the user_id, then o.logs.find_by_user(current_user), etc...
== Database
class CreateLoggable < ActiveRecord::Migration
def self.up
create_table "logs" do |t|
t.string "message"
t.integer "loggable_id"
t.string "loggable_type"
t.integer "user_id"
t.timestamps
end
create_table "log_details" do |t|
t.integer "log_id"
t.string "label"
t.text "detail"
end
end
def self.down
drop_table :logs
drop_table :log_details
end
end




