Skip to content

Commit

Permalink
Fix .count with .select in light of Rails 4.1 change
Browse files Browse the repository at this point in the history
  • Loading branch information
Throne3d committed May 24, 2017
1 parent 52f97e6 commit c2ecf29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/_generate_flat.haml
Original file line number Diff line number Diff line change
@@ -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}
Expand Down

0 comments on commit c2ecf29

Please sign in to comment.