From 3e03e37533826643f6f073e78bcc341ce0ed3c7b Mon Sep 17 00:00:00 2001 From: Edward Jones Date: Wed, 24 May 2017 18:39:22 +0100 Subject: [PATCH] Fix .count with .select in light of Rails 4.1 change See https://github.com/rails/rails/pull/10710 --- app/controllers/application_controller.rb | 2 +- app/views/posts/_generate_flat.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ceeef90914..1f1a6826cf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -107,7 +107,7 @@ def posts_from_relation(relation, no_tests=true, with_pagination=true) posts = posts.paginate(page: page, per_page: 25) if with_pagination posts = posts.no_tests if no_tests - if (with_pagination && posts.total_pages <= 1) || posts.count <= 25 + if (with_pagination && posts.total_pages <= 1) || posts.count(:all) <= 25 posts = posts.select {|post| post.visible_to?(current_user)} end diff --git a/app/views/posts/_generate_flat.haml b/app/views/posts/_generate_flat.haml index 7fe43c7cf9..05f1ca93bb 100644 --- a/app/views/posts/_generate_flat.haml +++ b/app/views/posts/_generate_flat.haml @@ -1,4 +1,4 @@ -- 1.upto((replies.count / 250.0).ceil).each do |index| +- 1.upto((replies.count(:all) / 250.0).ceil).each do |index| - replies.paginate(per_page: 250, page: index).each do |reply| - klass = cycle('even'.freeze, 'odd'.freeze) .post-container{class: klass}