I'm trying to find the best solution to filter the objects in a has_many association. What I have for a setup is
class Company < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
attr_accessible :title
belongs_to :company
end
Then in my CompaniesController#show method what I'd like to do is filter the products by it's title.
def show
@company = Company.find(params[:id])
# Then I just want the @company.products where title = params[:title]
end
Any help would be greatly appreciated.