title: Smart_listing Gem sorting
body: <p>Im integrating <a href="https://github.com/Sology/smart_listing" rel="nofollow">Smart_listing</a> gem onto my Rails App. I have a <strong><em>Beer table</em></strong> in my database and a <strong><em>beer_type</em></strong> column. Right now im trying to set up a sorting function where Users can filter different types of beer. Similar to this functionality <a href="http://sf.hopsy.beer/menu" rel="nofollow">example</a>.</p>
  
  <p>Right now it will filter each one type of beer perfectly. However whenever there is more than 1 beer type checked, it would not display the beer types together.</p>
  
  <blockquote>
    <p>product.rb</p>
  </blockquote>
  
  <pre><code>scope :with_beer_type_ales, -&gt; (product) { where('beer_type ILIKE?', "%ales%") }
  scope :with_beer_type_cream, -&gt; (product) { where('beer_type ILIKE?', "%cream%") }
  scope :like, -&gt;(args) { where("name ILIKE? OR beer_type ILIKE? OR description ILIKE?", "%#{args}%", "%#{args}%", "%#{args}%")}
  </code></pre>
  
  <blockquote>
    <p>products_controller.rb</p>
  </blockquote>
  
  <pre><code>def index
   products_scope = Product.all
   # Make users initally sorted by name ascending
   products_scope = products_scope.like(params[:filter]) if params[:filter]
  
  
   products_scope=products_scope.with_beer_type_ales(params[:with_beer_type_ales]) if params[:with_beer_type_ales] == "1"
  products_scope = products_scope.with_beer_type_cream(params[:with_beer_type_cream]) if  params[:with_beer_type_cream] == "1"
  
   @products = smart_listing_create :products, 
                         products_scope, 
                         partial: "products/list",
                         page_sizes: [10, 20, 30], 
                         default_sort: {name: "asc"}
  end
  </code></pre>
  
  <blockquote>
    <p>index.html.erb</p>
  </blockquote>
  
  <pre><code>&lt;%= smart_listing_controls_for(:products, {class: "form-inline text-left"}) do %&gt;
       &lt;div class="form-group filter input-append" id="search"&gt;
          &lt;%= text_field_tag :filter, '', class: "search form-control",  
            placeholder: "Search...", autocomplete: :off %&gt;
            &lt;button class="btn btn-primary disabled" type="&lt;%= :submit %&gt;"&gt;
              &lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt;
            &lt;/button&gt;
        &lt;/div&gt;
  
          &lt;h4&gt;Sort By Type:&lt;/h4&gt;
          &lt;ul&gt;
              &lt;li class="checkbox"&gt;
                  &lt;label class="checkbox inline"&gt;
                &lt;%= hidden_field_tag :with_beer_type_ales, "0" %&gt;
                &lt;%= check_box_tag :with_beer_type_ales %&gt; Ales
              &lt;/label&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;label class="checkbox inline"&gt;
                  &lt;%= hidden_field_tag :with_beer_type_cream, "0" %&gt;
                &lt;%= check_box_tag :with_beer_type_cream %&gt; Cream
              &lt;/label&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>