コントローラーにこれがあります:
class User::ResourcesController < User::UserController
def index
@resource_type = ResourceType.find_by_name(params[:resource_type].to_s.titleize)
@products = @products.includes(:resources).where(:resources => { :resource_type_id => @resource_type.id })
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @resources }
end
end
end
リソースをフィルタリングしようとしているので、私の見解では、以下のコードを使用して、正しい resource_type_id を持つリソースのみをプルすることができます。
@products.each do |product|
product.resources.count
end