title: How can i filter results in the view using includes in the controller in rails 3?
body: <p>I have this in my controller:</p>
  
  <pre><code>class User::ResourcesController &lt; User::UserController
    def index
       @resource_type = ResourceType.find_by_name(params[:resource_type].to_s.titleize)
       @products = @products.includes(:resources).where(:resources =&gt; { :resource_type_id =&gt; @resource_type.id })
  
       respond_to do |format|
         format.html # index.html.erb
         format.xml  { render :xml =&gt; @resources }
       end
    end
  end
  </code></pre>
  
  <p>I am trying to get my resources to be filtered so in my view i can use the code below and have it only pull the resources that have the correct resource_type_id.</p>
  
  <pre><code>@products.each do |product|
    product.resources.count
  end
  </code></pre>