joep
1
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?
joep
2
On 11 Dec 2008, at 16:05, Joe P. wrote:
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
joep
3
Frederick C. wrote:
On 11 Dec 2008, at 16:05, Joe P. wrote:
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
Beautiful. Thanks Fred, you seem to answer a lot of questions on this
board.