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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -