Commit d7e3310e5f6321f78f25d79e80603c182d5292b9
1 parent
bff30612
Exists in
relation
Better model handling [skip ci]
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -222,11 +222,17 @@ module Searchkick |
222 | 222 | end |
223 | 223 | |
224 | 224 | def models(*args) |
225 | + raise ArgumentError, "Use Searchkick.search to search multiple models" if klass | |
225 | 226 | spawn.models!(*args) |
226 | 227 | end |
227 | 228 | |
228 | 229 | def models!(*args) |
229 | - options[:models] = Array(options[:models]) + args | |
230 | + # make Searchkick.search.models(Product) and Product.search equivalent | |
231 | + if !klass && args.size == 1 && !options[:models] | |
232 | + @klass = args.first | |
233 | + else | |
234 | + options[:models] = Array(options[:models]) + args | |
235 | + end | |
230 | 236 | self |
231 | 237 | end |
232 | 238 | ... | ... |