dimkiriyenko-kaminari 0.12.5 → 0.12.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -4
- data/lib/kaminari/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -63,11 +63,11 @@ Then bundle:
|
|
63
63
|
|
64
64
|
* the +smart_count+ method
|
65
65
|
|
66
|
-
+
|
66
|
+
ActiveRecord +count+ method may fail or give wrong results on complex queries. Say, for example, you use +having+ constraint, based on +select+ generated columns. As long as generated columns are thrown away, +having+ constraint will fail and you will get invalid query. If this is your case, you should define a +smart_count+ method on your model or scope. A possible implementation may be (works with any complex query):
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
def smart_count
|
69
|
+
count_by_sql("SELECT COUNT(*) FROM (#{scoped.to_sql}) AS count_table")
|
70
|
+
end
|
71
71
|
|
72
72
|
Kaminari will call this method instead of +count+ if it is defined.
|
73
73
|
|
data/lib/kaminari/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimkiriyenko-kaminari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 12
|
9
|
-
-
|
10
|
-
version: 0.12.
|
9
|
+
- 6
|
10
|
+
version: 0.12.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|