From eb3694dbe6bab546527507e6cf3145220ec65ffe Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 17 Jun 2016 14:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- app/views/users/_user_message_course.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ca63f496c..87c7d8f54 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -132,7 +132,7 @@ class UsersController < ApplicationController # 未读的消息存放在数组 mess = message_all.message if (message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end break if @message_alls.length == 5 @@ -166,7 +166,7 @@ class UsersController < ApplicationController messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") messages.each do |message_all| mess = message_all.message - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end end @@ -177,7 +177,7 @@ class UsersController < ApplicationController # 在点击或者刷新消息列表后未读的消息存放在数组 mess = message_all.message if message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed) - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end end diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 0c18dbcc3..3e83b0f7a 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -326,7 +326,7 @@ <% end %> - <% if ma.course_message_type == "StudentWorksScore" %> + <% if ma.course_message_type == "StudentWorksScore" && ma.course_message %>