发布问卷时,该问卷才显示在动态,取消发布后取消显示该动态

This commit is contained in:
sw 2015-08-14 14:44:31 +08:00
parent 35d6c76a8e
commit 50fa03d00c
1 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,7 @@ class Poll < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
after_create :act_as_activity, :act_as_course_activity
before_save :act_as_activity, :act_as_course_activity
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
@ -32,7 +32,11 @@ class Poll < ActiveRecord::Base
#课程动态公共表记录
def act_as_course_activity
if self.polls_type == "Course"
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
if self.polls_status == 2 #问卷是发布状态
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
elsif self.polls_status == 1 #问卷是新建状态
self.course_acts.destroy_all
end
end
end
end