课程动态,无对应数据时报错

This commit is contained in:
sw 2015-08-13 15:00:13 +08:00
parent 4b5022bfc6
commit 3e9f3f4e70
1 changed files with 24 additions and 22 deletions

View File

@ -682,28 +682,30 @@ module CoursesHelper
# activity = CourseActivity.first
title = ""
url = ""
case activity.course_act_type
when "Course"
title = activity.course_act.name
url = course_path activity.course
when "HomeworkCommon"
title = "作业 " + activity.course_act.name
url = student_work_index_path(:homework => activity.course_act.id)
when "News"
title = "通知公告 " + activity.course_act.title
url = course_news_index_path(activity.course)
when "Attachment"
title = "课件 " + activity.course_act.filename
url = course_files_path(activity.course)
when "Message"
title = "课程讨论区 " + activity.course_act.subject
url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
when "JournalsForMessage"
title = "留言 " + activity.course_act.notes
url = course_feedback_path(activity.course)
when "Poll"
title = "问卷 " + activity.course_act.polls_name
url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id)
if activity.course_act
case activity.course_act_type
when "Course"
title = activity.course_act.name
url = course_path activity.course
when "HomeworkCommon"
title = "作业 " + activity.course_act.name
url = student_work_index_path(:homework => activity.course_act.id)
when "News"
title = "通知公告 " + activity.course_act.title
url = course_news_index_path(activity.course)
when "Attachment"
title = "课件 " + activity.course_act.filename
url = course_files_path(activity.course)
when "Message"
title = "课程讨论区 " + activity.course_act.subject
url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
when "JournalsForMessage"
title = "留言 " + activity.course_act.notes
url = course_feedback_path(activity.course)
when "Poll"
title = "问卷 " + activity.course_act.polls_name
url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id)
end
end
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
end