From b2d0cd7f73f9727960940e42a70229fb07af478f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 29 Dec 2016 21:07:03 -0800 Subject: [PATCH] Better error message when no primary key - closes #779 --- .travis.yml | 2 +- lib/searchkick/results.rb | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff1bee4..28c077b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ matrix: env: ELASTICSEARCH_VERSION=2.0.0 jdk: oraclejdk7 - gemfile: Gemfile - env: ELASTICSEARCH_VERSION=2.4.1 + env: ELASTICSEARCH_VERSION=2.4.3 jdk: oraclejdk7 - gemfile: Gemfile env: ELASTICSEARCH_VERSION=5.0.1 diff --git a/lib/searchkick/results.rb b/lib/searchkick/results.rb index 31bc68a..8ca8174 100644 --- a/lib/searchkick/results.rb +++ b/lib/searchkick/results.rb @@ -205,13 +205,10 @@ module Searchkick if records.respond_to?(:primary_key) && records.primary_key # ActiveRecord records.where(records.primary_key => ids) - elsif records.respond_to?(:all) && records.all.respond_to?(:for_ids) - # Mongoid 2 - records.all.for_ids(ids) elsif records.respond_to?(:queryable) # Mongoid 3+ records.queryable.for_ids(ids) - elsif records.respond_to?(:unscoped) && [:preload, :eager_load].any? { |m| records.all.respond_to?(m) } + elsif records.respond_to?(:unscoped) && :id.respond_to?(:in) # Nobrainer records.unscoped.where(:id.in => ids) else -- libgit2 0.21.0