ruby on rails - Limit pg_search to the associations of an individual User object -
for example:
class user < activerecord::base has_many :cars end # name :string(255) class car < activerecord::base belongs_to :user end
how use pg_search full text search of names of cars single user instance has (versus cars)?
i'm author of pg_search. sounds want chain pg_search_scope onto association:
class user < activerecord::base has_many :cars end class car < activerecord::base include pgsearch belongs_to :user pg_search_scope :search_by_name, against: :name end user = user.find(1) user.cars.search_by_name("ford")
Comments
Post a Comment