Commit 3a3c83197c915e8cc79262d6f96344186c176359
1 parent
4bf7bc8f
Exists in
master
and in
17 other branches
Only show warning once
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -63,10 +63,6 @@ module Searchkick |
63 | 63 | # there can be multiple models per index name due to inheritance - see #1259 |
64 | 64 | (@index_mapping[model.searchkick_index.name] ||= []) << model |
65 | 65 | end |
66 | - | |
67 | - if options[:per_page] && @index_mapping.values.flatten.any? { |m| m != m.searchkick_klass } | |
68 | - warn "[searchkick] Passing child models to the models option throws off pagination" | |
69 | - end | |
70 | 66 | end |
71 | 67 | |
72 | 68 | index = |
... | ... | @@ -136,6 +132,12 @@ module Searchkick |
136 | 132 | suggest: options[:suggest] |
137 | 133 | } |
138 | 134 | |
135 | + # not great place, but params method is called multiple times | |
136 | + # and we want warning to show up only once | |
137 | + if options[:models] && options[:per_page] && @index_mapping.values.flatten.any? { |m| m != m.searchkick_klass } | |
138 | + warn "[searchkick] WARNING: Passing child models to the models option throws off pagination - use type option instead" | |
139 | + end | |
140 | + | |
139 | 141 | if options[:debug] |
140 | 142 | require "pp" |
141 | 143 | ... | ... |