title: Ruby on Rails search with multiple parameters
body: <p>For example in my Car model i have such fields:</p>
  
  <pre><code>color, price, year
  </code></pre>
  
  <p>and in form partial i generate form with all this fields. But how to code such logic:</p>
  
  <p>user could enter color and year and i must find with this conditions, user could enter just year or all fields in same time...</p>
  
  <p>And how to write where condition? I could write something like:</p>
  
  <pre><code>if params[:color].present?
  car = Car.where(color: params[:color])
  end
  
  if params[:color].present? &amp;&amp; params[:year].present?
  car = Car.where(color: params[:color], year: params[:year])
  end
  and so over....
  </code></pre>
  
  <p>But this is very ugly solution, i'm new to rails, and want to know: how is better to solve my problem?</p>