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