Code Monkey home page Code Monkey logo

acts_as_scribe's Introduction

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."

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::Base
    belongs_to :author, :class_name => "User"
    record_activity_of :author
  end

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

If you record activities different than the default create and destroy you can specify the :actions option

  class Post < ActiveRecord::Base
    belongs_to :author, :class_name => "User"
    record_activity_of :author, :actions => [:create, :update, :destroy]
  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)
    user.admin = true
    Activity.report(current_user, :grant_admin, user)
  end

If the action is not related to any item, just don't use it.

  def login
    current_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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.