0
st = 'pen'
ak = '123123'
agreements = Client.where{authentication_key == ak}.first.agreements
products = Product.joins{agreements}.where{agreements.id.in(a) & (short_description.like(st) | long_description.like(st))}
我与上面的努力,但我需要在我的结果设置得匹配的协议..怎样包括在结果中加入记录使用squeel
因为这
class Product < ActiveRecord::Base
has_and_belongs_to_many :agreements, uniq: true
的
我无法使用products.first.agreement.first ....这可能是一个不同的协议。
这是最接近的: Product.joins {agreements} .where {agreements.id.in(a)&(short_description.like(st)| long_description.like(st))}。select {[agreements.agreement_type ,id]} 但不是id我希望从产品的一切 – Boti 2013-02-25 18:06:55