On the relationship you can specify an order, like so:
has_many :comments, :order => "posted_on"
So you need a column in the DB which provides the ordering. See
http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html
for more information.
sam
On 5/3/05, David Corbin <dcorbin-wmGZ+vDKSyrZJqsBc5GL+g@public.gmane.org>
wrote:> One of my model objects has a collection of other model objects, and
I''d like
> that list to be "always ordered". Since it is (presumably) being
read from
> the database on demand, what''s the best way to do this?
>
> David
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
sam
http://www.magpiebrain.com/