2014-10-23 11:30:34 +08:00
|
|
|
class Activity < ActiveRecord::Base
|
|
|
|
attr_accessible :act_id, :act_type, :user_id
|
|
|
|
belongs_to :act, :polymorphic => true
|
|
|
|
belongs_to :user
|
2015-07-17 15:07:01 +08:00
|
|
|
belongs_to :activity_container, polymorphic: true
|
2014-10-23 11:30:34 +08:00
|
|
|
validates :act_id, presence: true
|
|
|
|
validates :act_type, presence: true
|
|
|
|
validates :user_id, presence: true
|
2015-06-18 09:13:20 +08:00
|
|
|
|
|
|
|
include Trustie::Cache::ClearCourseEvent
|
2015-07-16 10:26:09 +08:00
|
|
|
|
|
|
|
before_create :set_container_type_val
|
|
|
|
|
|
|
|
#helper :activities
|
|
|
|
include ActivitiesHelper
|
|
|
|
def set_container_type_val
|
2015-07-18 17:01:22 +08:00
|
|
|
params =get_container_type(self)
|
|
|
|
self.activity_container_type = params[0]
|
|
|
|
self.activity_container_id = params[1]
|
|
|
|
if(self.act_type == 'JournalsForMessage')
|
|
|
|
self.user_id = params[2]
|
|
|
|
end
|
2015-07-16 10:26:09 +08:00
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
end
|