Module: PublicActivity::ORM::ActiveRecord::Activist

Defined in:
lib/public_activity/orm/active_record/activist.rb

Overview

Module extending classes that serve as owners

Instance Method Summary collapse

Instance Method Details

#activistObject

Adds ActiveRecord associations to model to simplify fetching so you can list activities performed by the owner. It is completely optional. Any model can be an owner to an activity even without being an explicit activist.

== Usage: In model:

class User < ActiveRecord::Base include PublicActivity::Model activist end

In controller: User.first.activities_as_owner or User.first.activities_as_recipient


24
25
26
27
28
29
30
31
# File 'lib/public_activity/orm/active_record/activist.rb', line 24

def activist
  has_many :activities_as_owner,
    :class_name => "::PublicActivity::Activity",
    :as => :owner
  has_many :activities_as_recipient,
    :class_name => "::PublicActivity::Activity",
    :as => :recipient
end