Sorting

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

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

./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

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

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

It has to have DESC at the end

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs