Forum: Ruby on Rails Just another syntax question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Geoff (Guest)
on 2005-12-17 22:54
(Received via mailing list)
Drag list order

I have an 'each do' loop iterating through the results
of an 'ordered'  'DB.find' . It appears that regardless of
the order of the 'find', the 'each do' loop serves it up and
displays in the order of  the '' ie id '1' first 'id' 2 second etc.

However I wish the order as viewed to not be in the order
 of the 'id' field but in the order of another field in the DB
which is changed by the drag action.
 ie each do by some other field than id

Cant quite get a handle on the syntax -
some variation of the each do or something else entirely
or am I missing the bleedin obvious
Steven S. (Guest)
on 2005-12-18 03:17
(Received via mailing list)
Try adding something like

	:order => "column_name DESC"

to your find as in

	DB.find(:all, :order => "column_name DESC")

where column_name is the column you wish to order by.  DESC can also
be ASC I assume.
This topic is locked and can not be replied to.