title: Rails 3: convert session[:params] to correct activerecord query
body: <p>I have two models, Foo and Bar, with same attributes, and I'm 'caching' user "search params" into a session variable, that ends into something like this:</p>
  
  <pre><code>session[:search_params] =&gt; {"price"=&gt;"15.0", "air_conditioner"=&gt;"0", "fireplace"=&gt;"0", "number_of_rooms"=&gt;"1", "balcony"=&gt;"0"} 
  </code></pre>
  
  <p>I'd like to search both <code>Foo</code> and <code>Bar</code> for entries that match this query.</p>
  
  <p>For now, I'm doing:</p>
  
  <pre><code>@foo = Foo.new(session[:search_params])
  search_attributes = @foo.attributes
  search_attributes.delete 'id'
  search_attributes.delete 'created_at'
  search_attributes.delete 'updated_at'
  @results = Foo.where(search_attributes)
  @results += Bar.where(search_attributes)
  </code></pre>
  
  <p>that is REALLY UGLY.</p>
  
  <p>Could anyone tell me a better/the correct way?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Also, some params in the <code>session[:search_params]</code> that are "0", are actually 'false' on the database (booleans) (filled by checkboxes), so I have to do some "conversion" into this fields so that the <code>query</code> is done correctly, i.e., getting for example <code>air_conditioner =&gt; 'false'</code>    instead of   <code>air_conditioner =&gt; '0'</code>.</p>