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 !
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---