Select count(*) using Ruby on Rails

Hullo. Welcome to my question.

In my controller I need to get the number of items in a table.

If I was just using MySQL, I'd do "select count(*) from blah where blah blah blah".

What is the way to do this in my controller? I'd like to avoid something like Blah.find(:all, :conditions => blah blah).size

Is there a way to do the equivalent of select count(*) in the controller?

Hullo. Welcome to my question.

In my controller I need to get the number of items in a table.

If I was just using MySQL, I'd do "select count(*) from blah where
blah blah blah".

What is the way to do this in my controller? I'd like to avoid something like Blah.find(:all, :conditions => blah blah).size

Blah.count(:all, :conditions => ...)

or if you had a named_scope for that set of conditions,
Blah.some_scope.count

Fred

Frederick Cheung wrote: