I have Articles and Comments. Comments are RESTfully nested in Articles
(articles/1/comments/2 etc).
I am attempting to display articles via how recently created their last
comment was – basically how any forum is ordered. How would I do this?
Thank you very much.
On Sat, Aug 9, 2008 at 10:07 PM, Kyle M. <
[email protected]> wrote:
I am attempting to display articles via how recently created their last
comment was – basically how any forum is ordered. How would I do this?
Thank you very much.
One possible approach is to:
-
add a commented_at timestamp column to Article.
-
in your Comment model, put in code for after_create to set the
parent
Article’s commented_at column to the current date time.
-
now, when you do Article.find, just add an option for :order =>
‘commented_at DESC’
Hope this helps.
Franz