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.
mizage (Guest)
on 2005-12-08 22: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
brianvh (Guest)
on 2005-12-08 22: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
ksruby (Guest)
on 2005-12-08 22: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.