[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Count results of a query?

(D. Alvarado)

2/28/2008 10:53:00 PM

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
1 Answer

Ilan Berci

2/28/2008 11:42:00 PM

0

laredotornado wrote:
> 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
--
Posted via http://www.ruby-....