title: Ransack Sorting, scope and ransacker
body: <p>Let say I am willing to do the search for my listing site with two fields one for city and other for listing name.</p>
  
  <p>But in my search page. I also want to add some filters to this search. My model also contains tags using <code>acts_as_taggable_on</code>.</p>
  
  <p>Basically a search similar to yelp.com</p>
  
  <ol>
  <li>How to update the params when clicking the checkbox of tags.</li>
  <li>Also need to add the sorting with <code>Best Match, Highest Rated and Most Reviewed</code>.</li>
  <li><p>For Highly Rated. I am having a <code>average_rating</code> method which will output the integer value. Need to take that value with the <code>ransacker</code>. The method i am using in shown below.</p>
  
  <pre><code>def average_rating
    total = self.comments.map do |c|
      c.rating
    end.reduce(0, :+)
    total == 0 ? 0.0 : average = total/self.comments_count.to_f
  end
  
  ransacker :average_rating do
    "what need to be mentioned here."
  end
  </code></pre></li>
  </ol>