Count results of a query?

L

laredotornado

Hi,

I have this code

@users = find:)all, :conditions => conditions, :page => {:size =>
page_size, :current => page_num} )
if (@users.count == 0)
flash[:notice] = "No results found."
render :action => 'search'
end

but as many of you can guess, it gives me a "undefined method: count"
error. Same if I try "length". What is the right way to count the
results of the query? - Dave
 
I

Ilan Berci

laredotornado said:
Hi,

I have this code

@users = find:)all, :conditions => conditions, :page => {:size =>
page_size, :current => page_num} )
if (@users.count == 0)
flash[:notice] = "No results found."
render :action => 'search'
end

but as many of you can guess, it gives me a "undefined method: count"
error. Same if I try "length". What is the right way to count the
results of the query? - Dave

@users.size


In the future, simply open up irb and type the following
@users.methods - Object.instance_methods

hth

ilan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top