项目新闻、项目讨论区区分project和course

This commit is contained in:
huang 2016-01-13 10:18:19 +08:00
parent 64088f5a21
commit 5519ef78e2
2 changed files with 6 additions and 4 deletions

View File

@ -127,7 +127,7 @@ class Message < ActiveRecord::Base
# 发帖精辟更新发帖总数
def add_boards_count
if self.parent_id.nil?
if self.project && self.parent_id.nil?
count = self.project.boards_count + 1
self.project.update_attribute(:boards_count, count)
end
@ -313,7 +313,7 @@ class Message < ActiveRecord::Base
# 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
def decrease_boards_count
if self.parent_id.nil?
if self.project && self.parent_id.nil?
count = self.project.boards_count - 1
self.project.update_attribute(:boards_count, count)
end

View File

@ -169,8 +169,10 @@ class News < ActiveRecord::Base
end
def decrease_news_count
count = self.project.news_count - 1
self.project.update_attribute(:news_count, count)
if self.project
count = self.project.news_count - 1
self.project.update_attribute(:news_count, count)
end
end
def send_mail