thecocktail / acts_as_scribe forked from linkingpaths/acts_as_scribe
- Source
- Commits
- Network (1)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Tue Feb 24 08:41:16 -0800 2009 | |
| |
MIT-LICENSE | Mon Sep 15 02:34:13 -0700 2008 | |
| |
README.markdown | Tue May 05 02:12:01 -0700 2009 | |
| |
Rakefile | Tue Feb 24 10:14:36 -0800 2009 | |
| |
VERSION.yml | Tue Feb 24 08:43:47 -0800 2009 | |
| |
acts_as_scribe.gemspec | Tue Feb 24 10:14:36 -0800 2009 | |
| |
features/ | Mon May 04 09:12:17 -0700 2009 | |
| |
generators/ | Tue Feb 24 10:14:36 -0800 2009 | |
| |
init.rb | Mon Sep 15 02:34:13 -0700 2008 | |
| |
lib/ | Tue May 12 08:06:56 -0700 2009 | |
| |
spec/ | Mon May 04 09:12:17 -0700 2009 |
ActsAsScribe
A simple plugin that allows to keep history records of the users activities. Common uses could be user's wall, public timeline portlets, etc...
Scribe (From Wikipedia, the free encyclopedia): "A scribe was traditionally a person who could read and write. This usually indicated secretarial and administrative duties such as dictation and keeping business, judicial, and history records for kings, nobles, temples, and cities."
Changes in this fork
The model 'Activity' is now defined as a module called 'ScribeActivity' so, know, you can define a model in your app, for example 'Activity' and include the module like this:
class Activity < ActiveRecord::Base
include ScribeActivity
end
so you can complete your model with some actions, finders, etc ...
Resources
Install
- Run the following command:
script/plugin install git://github.com/linkingpaths/acts_as_scribe.git
- Generate the tables via the given generator:
script/generate acts_as_scribe_migration
- And finally...
rake db:migrate
Record activities in your models
class Comment < ActiveRecord::Base
record_activity_of :user
end
You can use any association that is related to an user:
class Post < ActiveRecord::Basebelongs_to :author, :class_name => "User" record_activity_of :authorend
This will register automatically a new activity when you create or destroy a new record. If you want control over the activities registration based on your model's state just use the :if option
class Post < ActiveRecord::Base
belongs_to :author, :class_name => "User"
record_activity_of :author, :if => Proc.new { |post| post.private == false }
end
Record activities without related item
If you want to record activities not related to any specific model just use Activity.report in your code:
def grant_admin(user)If the action is not related to any item, just don't use it.user.admin = true Activity.report(current_user, :grant_admin, user)end
def logincurrent_user = User.find(…) Activity.report(current_user, :login)end
More
http://github.com/linkingpaths/acts_as_scribe
http://github.com/linkingpaths/acts_as_scribe/wikis
Copyright (c) 2008 Linking Paths, released under the MIT license
