Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Active Record: fix `total_entries` on grouped relations

  • Loading branch information...
commit 87f827d4e13fbe386179b7016ccc831cf0ce0771 1 parent f3f9df0
@mislav authored
View
4 lib/will_paginate/active_record.rb
@@ -49,7 +49,9 @@ def total_entries
offset_value + size
else
@total_entries_queried = true
- count
+ result = count
+ result = result.size if result.respond_to?(:size) and !result.is_a?(Integer)
+ result
end
end
end
View
4 spec/finders/active_record_spec.rb
@@ -161,6 +161,10 @@
$query_sql.last.should =~ /\bJOIN\b/
end
+
+ it "should count with group" do
+ Developer.group(:salary).page(1).total_entries.should == 4
+ end
end
it "should not ignore :select parameter when it says DISTINCT" do
Please sign in to comment.
Something went wrong with that request. Please try again.