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)
1919
2020 def self . create ( results , total_hits , options = { } )
2121 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
2326
2427 if array . empty? && !results . empty?
2528 # since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param
2629 # otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d
2730 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
2932 end
3033
3134 array
You can’t perform that action at this time.
0 commit comments