Skip to content
Browse files

Active Record: fix `total_entries` on grouped relations

  • Loading branch information...
1 parent f3f9df0 commit 87f827d4e13fbe386179b7016ccc831cf0ce0771 @mislav committed
Showing with 7 additions and 1 deletion.
  1. +3 −1 lib/will_paginate/active_record.rb
  2. +4 −0 spec/finders/active_record_spec.rb
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

0 comments on commit 87f827d

Please sign in to comment.
Something went wrong with that request. Please try again.