will_paginate and :order

Hi!

I would like to code a kind of 'forum'.

I'm using will_paginate and I would like my topics to be order by the newest answer by topic.

For the moment I have: - in my controller: [code] @categorie = Categoriemessage.find(params[:id]) @souscategories = Categoriemessage.find(:all, :conditions => ["parent_id = ?", params[:id]]) @sujets = Message.paginate :per_page => 10, :page => params[:page],                             :conditions => ["sujet_id = ? AND categorie_id = ?", '0',params[:id]] [/code]

- in my helper: [code] def datedernierereponse(sujet_id)   m = Message.find(:first, :conditions => ["sujet_id = ?", sujet_id], :order => "datecreation desc")   if m.nil?     m = Message.find(sujet_id)   end     m.datecreation end [/code]

Like this, my application works. @categorie is the current category of the list @souscategories are the children's categories of @categorie. @sujets is the list of topics showed in the view. datededernierereponse(sujet_id) is a function giving the date of the newest answer of a topic.

I don't how to do: - order @sujets by the newest answer. - I would like @sujets to include the topics of the @souscategories, where 'categorie_id' = @souscategories.id

My english isn't so good, don't hesitate to ask for more explanation or a reformulation.

Thanks !

The second problem is solved (include the topics of @souscategories in my request)

Here is the code:

@souscategories = Categoriemessage.find(:all, :conditions => ["parent_id = ?", params[:id]]) categories = [@categorie] + @souscategories @sujets = Message.paginate :per_page => 10, :page => params[:page], :conditions => {:sujet_id => '0', :categorie_id => categories}

I still don't know how to order the request by the date of the newest answer. (As i mentionned, I have a helper method giving the date of the newest answer, it just need the id of the topic.

I can give more information if it's needed.