Forum: Ruby on Rails Sorting a db result set

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
74bdb7628960d0bc1cc62647cd105eca?d=identicon&s=25 mizage (Guest)
on 2005-12-08 21:01
hola!

#controller code which gets all the db records:
def list2
  @teams = Team.find_all
end

#rhtml code
@teams.each do |team|

the question is how do i do a "sort by" "columnX"?

cheers
7c4087d053eb02d099a17d91ba5e33b5?d=identicon&s=25 brianvh (Guest)
on 2005-12-08 21:21
(Received via mailing list)
mizage wrote:
> hola!
>
> #controller code which gets all the db records:
> def list2
>   @teams = Team.find_all
> end


@teams = Team.find :all, :order => "columnx"

-Brian
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 ksruby (Guest)
on 2005-12-08 21:25
(Received via mailing list)
def list2
  @teams = Team.find :all, :order => 'columnX'
end

Kent.
This topic is locked and can not be replied to.