ActivityTracker
===============
USAGE:
./script/generate activity_migration
# To track an 'unlinked' activity (one which does not directly associate with an object in your database)
class User < ActiveRecord::Base
tracks_unlinked_activities [:logged_in]
end
class SessionsController < ApplicationController
def create
self.current_user = User.authenticate(params[:login], params[:password])
if logged_in?
current_user.track_activity(:logged_in)
redirect_to '/'
else
render :action => 'new'
end
end
end
# To track a 'linked' activity (like the creation of a post)
# An activity will automatically be added every time a Post is created.
# the acts_as_activity method takes two arguments:
# :actor - the user model that owns this object. In most cases this will be :user. Required.
# :options - hash of options.
class Post < ActiveRecord::Base
belongs_to :user
acts_as_activity :user
end