title: Rails 3 Drop Down Index Page Filter Sort
body: <p>I am using Rails 3 and ruby 1.9.2. I have a storefront listing several products and I want to give users the ability to filter the products by <code>dept_type</code>. <code>dept_type</code> is a attribute of products and not a separate model. I have the following in my model:</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    DEPT_TYPES = ["Baby","Beauty", "Household", "Pets"]
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>class StoreController &lt; ApplicationController
    def index
      @title= "Home"
      if Product.all.collect(&amp;:dept) == (params[:dept])
        @products= Product.send(params[:dept])
      else
        @products = Product.order(:premium)
      end
    end
  </code></pre>
  
  <p>In my view:</p>
  
  <pre><code>&lt;%= select("dept", "dept_type", Product.all.collect(&amp;:dept)) %&gt;
    &lt;% @products.each do |product| %&gt;
      ...
    &lt;%end%&gt;
  </code></pre>
  
  <p>When I load the page I have the dropdown with all the <code>DEPT_TYPES</code> options but when I select one nothing happens. What do I need to do to get the page to update and filter for only the selected dept?</p>