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))}
I am trying with the above but I need the matched agreement in my result set too..
Because of this
class Product < ActiveRecord::Base
has_and_belongs_to_many :agreements, uniq: true
I cant use products.first.agreement.first.... That could be a different agreement.