From 50fa03d00cd0a2bdfd6184a68945ee5fb6d94a6b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:44:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=AF=A5=E9=97=AE=E5=8D=B7=E6=89=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=9C=A8=E5=8A=A8=E6=80=81=EF=BC=8C=E5=8F=96=E6=B6=88=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=90=8E=E5=8F=96=E6=B6=88=E6=98=BE=E7=A4=BA=E8=AF=A5?= =?UTF-8?q?=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..3adbbb791 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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