From 808b553e435314c0a714ba51af4d47bc5dbb69d0 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Jul 2016 16:50:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=8A=A8=E6=80=81=E5=8F=AA?= =?UTF-8?q?=E6=9C=8910=E6=9D=A1=EF=BC=8C=E5=BA=95=E9=83=A8=E5=8D=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E2=80=9C=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 18 ++++++++++-------- app/views/courses/_course_activity.html.erb | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 41ea9c45e..21dac6ada 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -888,23 +888,25 @@ class CoursesController < ApplicationController if params[:type].present? case params[:type] when "homework" - @course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc') when "news" - @course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc') when "message" - @course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc') when "poll" - @course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc') when "attachment" - @course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc') when "journalsForMessage" - @course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc') else - @course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.order('updated_at desc') end else - @course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10) + @course_activities = course_activities.order('updated_at desc') end + @course_activities_count = @course_activities.count + @course_activities = @course_activities.limit(10).offset(@page * 10) @type = params[:type] @left_nav_type = 1 diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index 16d151d83..993c767d6 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -78,7 +78,7 @@ <% end %> <% end %> -<% if course_activities.count == 10 %> +<% if course_activities.count + page * 10 < @course_activities_count %> <%= link_to "点击展开更多",course_activity_path(@course.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end %>