Commit 36db36808008022da93502b096878d32ff697f7f
1 parent
c2c48a84
Exists in
master
and in
21 other branches
Fixes for Mongoid 3.1.4
Showing
6 changed files
with
22 additions
and
7 deletions
Show diff stats
Gemfile
lib/searchkick.rb
... | ... | @@ -9,5 +9,5 @@ require "searchkick/tasks" |
9 | 9 | require "searchkick/logger" if defined?(Rails) |
10 | 10 | |
11 | 11 | # TODO find better ActiveModel hook |
12 | -ActiveModel::AttributeMethods::ClassMethods.send(:include, Searchkick::Model) | |
12 | +ActiveModel::Callbacks.send(:include, Searchkick::Model) | |
13 | 13 | ActiveRecord::Base.send(:extend, Searchkick::Model) if defined?(ActiveRecord) | ... | ... |
lib/searchkick/reindex.rb
... | ... | @@ -14,8 +14,12 @@ module Searchkick |
14 | 14 | |
15 | 15 | # use scope for import |
16 | 16 | scope = respond_to?(:search_import) ? search_import : self |
17 | - scope.find_in_batches do |batch| | |
18 | - index.import batch | |
17 | + if scope.respond_to?(:find_in_batches) | |
18 | + scope.find_in_batches do |batch| | |
19 | + index.import batch | |
20 | + end | |
21 | + else | |
22 | + index.import scope.all | |
19 | 23 | end |
20 | 24 | |
21 | 25 | if a = Tire::Alias.find(alias_name) | ... | ... |
lib/searchkick/search.rb
... | ... | @@ -28,7 +28,7 @@ module Searchkick |
28 | 28 | page = [options[:page].to_i, 1].max |
29 | 29 | per_page = options[:limit] || options[:per_page] || 100000 |
30 | 30 | offset = options[:offset] || (page - 1) * per_page |
31 | - index_name = options[:index_name] || index.name | |
31 | + index_name = options[:index_name] || tire.index.name | |
32 | 32 | |
33 | 33 | conversions_field = @searchkick_options[:conversions] |
34 | 34 | personalize_field = @searchkick_options[:personalize] | ... | ... |
test/index_test.rb
test/test_helper.rb
... | ... | @@ -35,7 +35,14 @@ Tire.configure do |
35 | 35 | pretty true |
36 | 36 | end |
37 | 37 | |
38 | +# Mongoid.configure do |config| | |
39 | +# config.connect_to "searchkick_test" | |
40 | +# end | |
41 | + | |
38 | 42 | class Product < ActiveRecord::Base |
43 | + # include Mongoid::Document | |
44 | + # include Mongoid::Attributes::Dynamic | |
45 | + | |
39 | 46 | belongs_to :store |
40 | 47 | |
41 | 48 | searchkick \ |
... | ... | @@ -64,9 +71,10 @@ class Product < ActiveRecord::Base |
64 | 71 | end |
65 | 72 | |
66 | 73 | class Store < ActiveRecord::Base |
74 | + # include Mongoid::Document | |
67 | 75 | end |
68 | 76 | |
69 | -Product.index.delete if Product.index.exists? | |
77 | +Product.tire.index.delete if Product.tire.index.exists? | |
70 | 78 | Product.reindex |
71 | 79 | Product.reindex # run twice for both index paths |
72 | 80 | |
... | ... | @@ -82,7 +90,7 @@ class MiniTest::Unit::TestCase |
82 | 90 | documents.shuffle.each do |document| |
83 | 91 | Product.create!(document) |
84 | 92 | end |
85 | - Product.index.refresh | |
93 | + Product.tire.index.refresh | |
86 | 94 | end |
87 | 95 | |
88 | 96 | def store_names(names) | ... | ... |