【发布时间】:2014-04-09 12:20:02
【问题描述】:
升级到 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
它工作正常,但现在 ActiveRecord 向我抛出这个错误:
Couldn't find all Products with 'id': (1118, 1036, {:include=>[:user, :tags]}) (found 2 results, but was looking for 3)
我的问题是如何使用轮胎宝石加载相关模型?
load:{:include => [:user, :tags] 正确吗?
提前感谢 JD。
【问题讨论】:
标签: ruby-on-rails activerecord ruby-on-rails-4 associations tire