title: Active record query interface in Ruby
body: <p>Can somebody assist on how I  can write this  custom query and an Active  Record query interface, I am still brand new to Ruby  and I read that Active record interface query  works on most databases so its recommended. Thank you in advance</p>
  
  <pre><code>sql = "select count(distinct(email)) as rcount from resources r
             inner join capabilities c
             on c.resource_id = r.id
             inner join skills s
             on c.skill_id = s.id "
  sql += " where " unless (params[:country_id].to_i.zero? &amp;&amp; params[:skill_id].to_i.zero?)
  
  sql += "r.nationality = '" + Country.get_country_name(params[:country_id]) + "'" unless (params[:country_id].to_i.zero?)
  
  sql += " and " unless (params[:country_id].to_i.zero? || params[:skill_id].to_i.zero?)
  
  sql += "s.id =" + params[:skill_id] unless (params[:skill_id].to_i.zero?)
  </code></pre>