Rails 4.1.0 elasticsearch轮胎协会

时间:2021-03-21 00:11:17

I'm getting an error with my (re)Tire gem integration after upgrading to Rails 4.1.0 Before i was running This code in my Product Model with Rails 4.0.4 :

升级到Rails 4.1.0之后,我的(重新)轮胎宝石集成出错了我运行之前在我的产品模型中使用Rails 4.0.4运行此代码:

def self.search(params)
  tire.search( load:{:include => [:user, :tags]}, match_all: {}, page: params[:page], per_page: 12) do
    sort do
        by :created_at, 'desc'
        end
    query do
      boolean do
        must { string params[:query], default_operator: "AND" } 
        must { term :online, true }
        must_not { string 'location:Undefined' }
      end
    end
  end
end

It was working fine, but now ActiveRecord throw me this error :

它工作正常,但现在ActiveRecord抛出这个错误:

Couldn't find all Products with 'id': (1118, 1036, {:include=>[:user, :tags]}) (found 2 results, but was looking for 3)

My question is how can i do to load associated models with Tire gem? is load:{:include => [:user, :tags] correct?

我的问题是如何使用Tire gem加载相关模型?是加载:{:include => [:user,:tags]正确吗?

Thanks in advance JD.

在此先感谢JD。

1 个解决方案

#1


0  

Tire performs the load using klass.find(ids, @options[:load]). This find behavious has been deprecated for a while but supported via a gem activerecord-deprecated_finders. Rails 4.1.0 removed the default dependency on that gem.

轮胎使用klass.find(ids,@ options [:load])执行加载。这种查找行为已被弃用了一段时间,但是通过gem activerecord-deprecated_finders支持。 Rails 4.1.0删除了该gem的默认依赖项。

You should be able to include the gem in your Gemfile yourself to restore the behaviour:

您应该能够自己在Gemfile中包含gem以恢复行为:

gem 'activerecord-deprecated_finders'

#1


0  

Tire performs the load using klass.find(ids, @options[:load]). This find behavious has been deprecated for a while but supported via a gem activerecord-deprecated_finders. Rails 4.1.0 removed the default dependency on that gem.

轮胎使用klass.find(ids,@ options [:load])执行加载。这种查找行为已被弃用了一段时间,但是通过gem activerecord-deprecated_finders支持。 Rails 4.1.0删除了该gem的默认依赖项。

You should be able to include the gem in your Gemfile yourself to restore the behaviour:

您应该能够自己在Gemfile中包含gem以恢复行为:

gem 'activerecord-deprecated_finders'