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))}
上記を試していますが、結果セットにも一致する一致が必要です..
このため
class Product < ActiveRecord::Base
has_and_belongs_to_many :agreements, uniq: true
products.first.agreement.first... は使えません。別の契約かもしれません。