title: Conditionally chaining where clauses in Rails ActiveRecord queries
body: <p>I have a form that when filled has to trigger a particular query, depending on which parameters the form has, so I have a method in my model that I believe should look like this:</p>
  
  <pre><code>def form_query(params)
  
    query = ''
    if params.has_key?('size')
      query = query.where(size: params['size'])
    end
  
    if params.has_key?('title')
      query = query.where(title: params['title'])
    end
  
    # More conditionals depending on params.
  end
  </code></pre>
  
  <p>My question is, what does <code>query</code> have to be at the beginning? I put <code>query = ''</code>, but I am wondering what has to be the base case, so I can conditionally add more 'where' clauses.</p>