In my application I have bots that have_many packs. Usually there is
just a big list with each bot and its packs. I’d like to add a filter
that shows only bots with packs matching a keyword (and only the
matching packs from those bots). I have sincerely no idea how to do this
properly.
The following works, but I doubt it’s really the proper way of doing
this:
class Bot < ActiveRecord::Base
has_many :packs, :order => ‘number’
def self.search(search)
has_many :packs, :order => ‘number’, :conditions => [‘name LIKE ?’,
search]
end
end