You can do it in a slow way:
YourModelClass.find(:all, :conditions => { :card_id => 5 }).count
or quick way:
YourModelClass.count(:conditions => { :card_id => 5 })
The fast method simply executes COUNT(*)inside the database, the slow method pushes the entire result from the database, turns it into objects, and then counts them.
Rails3 + :
YourModelClass.where(:card_id => 5).count
select count(*) from t where card_id = 5 . , :
YourModelClass.count(:card_id => 5)
select count(card_id = 5) from t , .