Commit b2d0cd7f73f9727960940e42a70229fb07af478f

Authored by Andrew Kane
1 parent dd4c1234

Better error message when no primary key - closes #779

Showing 2 changed files with 2 additions and 5 deletions   Show diff stats
.travis.yml
... ... @@ -26,7 +26,7 @@ matrix:
26 26 env: ELASTICSEARCH_VERSION=2.0.0
27 27 jdk: oraclejdk7
28 28 - gemfile: Gemfile
29   - env: ELASTICSEARCH_VERSION=2.4.1
  29 + env: ELASTICSEARCH_VERSION=2.4.3
30 30 jdk: oraclejdk7
31 31 - gemfile: Gemfile
32 32 env: ELASTICSEARCH_VERSION=5.0.1
... ...
lib/searchkick/results.rb
... ... @@ -205,13 +205,10 @@ module Searchkick
205 205 if records.respond_to?(:primary_key) && records.primary_key
206 206 # ActiveRecord
207 207 records.where(records.primary_key => ids)
208   - elsif records.respond_to?(:all) && records.all.respond_to?(:for_ids)
209   - # Mongoid 2
210   - records.all.for_ids(ids)
211 208 elsif records.respond_to?(:queryable)
212 209 # Mongoid 3+
213 210 records.queryable.for_ids(ids)
214   - elsif records.respond_to?(:unscoped) && [:preload, :eager_load].any? { |m| records.all.respond_to?(m) }
  211 + elsif records.respond_to?(:unscoped) && :id.respond_to?(:in)
215 212 # Nobrainer
216 213 records.unscoped.where(:id.in => ids)
217 214 else
... ...