title: Rails Active Record query with multiple optional params
body: <p>What would be the optimised way to create an ActiveRecord query in a Rails 4.1 application controller which can 0 to 4 optional query params, in absence of which I must return all the items: -</p>
  
  <pre><code>i) GET /tasks -&gt; returns all tasks
  
  ii) GET /tasks?created=10347892 -&gt; return tasks created after params[:created] timestamp
  
  iii) GET /tasks?nearTo=0,0 -&gt; return tasks near to 3 kms of params[:nearTo] geocoordinate
  
  iv) GET range=range1 -&gt; return tasks with range like 'range1' 
  
  v) of course we need to support the following query GET /tasks?created=1034589&amp;nearTo=0,0&amp;range=range1
  </code></pre>
  
  <p>Any help is appreciated.</p>