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