[英]Rails 4.1.0 elasticsearch Tire association
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后,我的(re)Tire gem集成出现错误,在运行Rails 4.0.4的Product Model
运行此代码之前:
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? 我的问题是我该怎么做才能用Tire gem加载相关模型? is load:{:include => [:user, :tags]
correct? load:{:include => [:user, :tags]
是否正确?
Thanks in advance JD. 预先感谢JD。
Tire performs the load using klass.find(ids, @options[:load])
. Tire使用klass.find(ids, @options[:load])
执行负载。 This find behavious has been deprecated for a while but supported via a gem activerecord-deprecated_finders . 这个行为已经过时了一段时间,但是通过gem activerecord-deprecated_finders支持 。 Rails 4.1.0 removed the default dependency on that gem. 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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.