Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix ActiveRecord empty? method on grouped results #161

Closed
wants to merge 1 commit into from

3 participants

@javierg

This is a prouposal fix based on 87f827

@phene

I get NoMethodError: undefined method <= for true:TrueClass

@phene

found the issue:

relation_count = count.respond_to?(:size) && !count.is_a?(Integer) ? count.size : count

instead of

relation_count = count.respond_to?(:size) and !count.is_a?(Integer) ? count.size : count

The 'and' keyword has a much lower OoO than &&

@javierg

Tnx, will prepare another pull request

@phene

Went ahead and prepared one: #178

@mislav mislav closed this in 8ce2276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/will_paginate/active_record.rb
View
3  lib/will_paginate/active_record.rb
@@ -80,8 +80,9 @@ def size
# overloaded to be pagination-aware
def empty?
+ relation_count = count.respond_to?(:size) and !count.is_a?(Integer) ? count.size : count
if !loaded? and offset_value
- count <= offset_value
+ relation_count <= offset_value
else
super
end
Something went wrong with that request. Please try again.