title: Rails way to COUNT the nr of records in my case
body: <p>I am using <strong>Rails v2.3.2</strong>.</p>
  
  <p>I have a <strong>model</strong> called <code>UsersCar</code>:</p>
  
  <pre><code>class UsersCar &lt; ActiveRecord::Base
    belongs_to :car
    belongs_to :user
  end
  </code></pre>
  
  <p>This <strong>model</strong> mapped to a database table <code>users_cars</code>, which only contains two columns : <code>user_id</code>, <code>car_id</code>.</p>
  
  <p>I would like to use <strong>Rails</strong> way to count the number of <code>car_id</code> <strong>where</strong> <code>user_id=3</code>. I konw in plain SQL query I can achieve this by:</p>
  
  <pre><code>SELECT COUNT(*) FROM users_cars WHERE user_id=3;
  </code></pre>
  
  <p>Now, I would like to get it by <strong>Rails</strong> way, I know I can do:</p>
  
  <pre><code>UsersCar.count()
  </code></pre>
  
  <p>but how can I put the <code>...where user_id=3</code> clause in <strong>Rails</strong> way? </p>