grosser / record_activities
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
MIGRATION | Thu Jan 08 04:02:38 -0800 2009 | |
| |
README.markdown | Wed Nov 18 04:02:48 -0800 2009 | |
| |
Rakefile | Wed Nov 18 04:03:12 -0800 2009 | |
| |
init.rb | Thu Jan 08 03:24:33 -0800 2009 | |
| |
lib/ | Fri Mar 13 03:15:43 -0700 2009 | |
| |
spec/ | Wed Nov 18 03:39:16 -0800 2009 |
README.markdown
- Simple activity logging build on top of userstamp
- Does not involve the controller
- Stores an Activity(:action, :actor, :subject) in the database
- Supports :create, :update, :save and :destroy by default + any user-defined action
Setup
- Install and setup userstamps
script/plugin install git://github.com/grosser/record_activities.git- Create an activities table for your database (see: MIGRATION)
- (Optional) Add
has_many :activities, :dependent => :destroy, :foreign_key => :actor_idto your user
Usage
class Comment < ActiveRecord::Base
stampable
record_activities :dependent => :destroy
end
Comment.create! --> Activity.create!(:subject => comment, :actor => current_user, :action => 'create')
record_activities is the same as record_activities :create, :update.
You may also use anything other than the supported :create / :update / :save / :destroy, but be sure to call the appropriate
callback model.record_activity_foo when the action foo was performed.
A Comment has_many :activities, if the :association or :dependent option is given:
record_activities :dependent => :destroy
record_activities :association => :something_else #this will use nullify, so your activities will not be cleaned up
Activity recording can be turned off by setting e.g. Comment.record_userstamp to false.
AUTHORS
Contributors
Author
Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...
