socialforge/app/models/activity.rb

22 lines
654 B
Ruby

class Activity < ActiveRecord::Base
attr_accessible :act_id, :act_type, :user_id
belongs_to :act, :polymorphic => true
belongs_to :user
belongs_to :activity_container, polymorphic: true
validates :act_id, presence: true
validates :act_type, presence: true
validates :user_id, presence: true
include Trustie::Cache::ClearCourseEvent
before_create :set_container_type_val
#helper :activities
include ActivitiesHelper
def set_container_type_val
container_type,container_id =get_container_type(self)
self.activity_container_type = container_type
self.activity_container_id = container_id
end
end