From 140cb81748976481e3569b581b8061e9dd463700 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 6 Mar 2015 11:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5=E5=92=8C=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=8F=91=E5=B8=83=E6=96=B0=E5=B8=96=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 7 +++++-- app/models/news.rb | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index 413a4f91c..85a87132d 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -164,8 +164,11 @@ class Message < ActiveRecord::Base # Author lizanle # Description def act_as_forge_activity - self.forge_acts << ForgeActivity.new(:user_id => self.author_id, - :project_id => self.board.project.id) + # 如果project为空,那么就是课程相关的消息 + if !self.board.project.nil? + self.forge_acts << ForgeActivity.new(:user_id => self.author_id, + :project_id => self.board.project.id) + end end #更新用户分数 -by zjc diff --git a/app/models/news.rb b/app/models/news.rb index fa9f31712..d2547fc02 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -98,8 +98,11 @@ class News < ActiveRecord::Base # Author lizanle # Description 公用表中也要记录 def act_as_forge_activity - self.forge_acts << ForgeActivity.new(:user_id => self.author_id, - :project_id => self.project.id) + # 如果是project为空,那么是课程相关的,不需要保存 + if !self.project.nil? + self.forge_acts << ForgeActivity.new(:user_id => self.author_id, + :project_id => self.project.id) + end end end