title: Avoid multiple queries to tables in rails
body: <p>I have list of two hospitals key-value selections in params[:hospitals],I am trying to write a query to get conditions row from Condition using params[:hospital] in the query below.</p>
  
  <pre><code>params[:hospitals].each do |hospital, xyz|
        &lt;!--code --&gt;
       Condition.find_by_hospital_id(Hospital.find_by_hospital_name(hospital).id)//query
  </code></pre>
  
  <p>Params contains</p>
  
  <pre><code>{"utf8"=&gt;"✓",
   "authenticity_token"=&gt;"",
   "client"=&gt;{"Client1"=&gt;"1"},
   "hospital"=&gt;{"hospital1"=&gt;"Client1", "hospital2" =&gt; "client2"},
   "type"=&gt;"BOTH",
   "beg-dt-tm"=&gt;"",
   "datepicker"=&gt;"",
   "end-dt-tm"=&gt;"",
   "controller"=&gt;"",
   "action"=&gt;""}
  </code></pre>
  
  <p>My question : Is there any better way to write a query by avoiding multiple calls to tables</p>
  
  <p>Thanks</p>