has_many 関連付けでオブジェクトをフィルター処理するための最適なソリューションを見つけようとしています。私がセットアップのために持っているのは
class Company < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
attr_accessible :title
belongs_to :company
end
次に、CompanysController#show メソッドで、商品をタイトルでフィルター処理します。
def show
@company = Company.find(params[:id])
# Then I just want the @company.products where title = params[:title]
end
どんな助けでも大歓迎です。