File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,16 @@ def initialize(array, options)
19
19
20
20
def self . create ( results , total_hits , options = { } )
21
21
offset = ( ( options [ :page ] - 1 ) * options [ :per_page ] )
22
- array = new results , limit : options [ :per_page ] , offset : offset , total_count : total_hits
22
+ total_hits = 0 if total_hits . nil?
23
+ offset = 0 if offset . nil?
24
+ limit = 0 if options [ :per_page ] . nil?
25
+ array = new results , limit : limit , offset : offset , total_count : total_hits
23
26
24
27
if array . empty? && !results . empty?
25
28
# since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param
26
29
# otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d
27
30
results = Array . new ( offset ) + results
28
- array = new results , offset : offset , limit : options [ :per_page ] , total_count : total_hits
31
+ array = new results , offset : offset , limit : limit , total_count : total_hits
29
32
end
30
33
31
34
array
You can’t perform that action at this time.
0 commit comments