Sorting


#1

I need to sort users by their rank how do I do this?


#2

Mohammad Surname? wrote:

I need to sort users by their rank how do I do this?

Assuming a User model with a comparable rank attribute,

@users = User.find(:all :order => “rank” )

Ray


#3

./script/…/config/…/app/controllers/users_controller.rb:12: parse
error, unexpected ‘:’, expecting ‘)’
@users = Users.find(:all :order => “points” )
^
./script/…/config/…/app/controllers/users_controller.rb:12: parse
error, unexpected ‘)’, expecting kEND
./script/…/config/…/app/controllers/users_controller.rb:51: parse
error, unexpected $, expecting kEND

this is the error I got when I ran it


#4

On Sun, 2006-04-16 at 05:11 +0200, Mohammad Surname? wrote:

./script/…/config/…/app/controllers/users_controller.rb:12: parse
error, unexpected ‘:’, expecting ‘)’
@users = Users.find(:all :order => “points” )
^
./script/…/config/…/app/controllers/users_controller.rb:12: parse
error, unexpected ‘)’, expecting kEND
./script/…/config/…/app/controllers/users_controller.rb:51: parse
error, unexpected $, expecting kEND

this is the error I got when I ran it


I would think that you would need a comma between :all and :order…

@users = Users.find(:all, :order => “points” )

Craig


#5

@users = Users.find(:all, :order => “points DESC” )

It has to have DESC at the end


#6

Craig W. wrote:

this is the error I got when I ran it


I would think that you would need a comma between :all and :order…

@users = Users.find(:all, :order => “points” )

True.

Ray


#7

Mohammad Surname? wrote:

@users = Users.find(:all, :order => “points DESC” )

It has to have DESC at the end

Also true, but only if the largest values are the highest rank.

That part of your question was unspecified.

Ray