I have a forum-type application. The Board model has many comments, the
Comments model acts as a tree. So I have a board with multiple
comments, some comments are parent comments and there are comments that
belong to a parent comment, making up a thread.
Like most forums, I want it so that threads are sorted based on the date
of their last comment. But I have no idea how to specify this in the
has_many :order of the Board model.
But more than this, I want it so that a thread can only be bumped X many
times; after the Xth comment the board
Previously I was doing it in a rather clunky way with a table column for
each parent comment that specifies when the thread was last replied to.
I don’t think this is the cleanest way of doing it but it works. Any
other ideas?
I would keep using the method with an extra column for last modified. It
seems to me the only other way to track this data would be to do a tree
traversal, and that would be a pain. Plus, with that extra column, you
can just :order by it.
Not a 100% solution, but it may get you further than acts_as_tree. You
can count children quite easily using the logic from acts_as_nested_set
and cut people off after X comments.
Ordering is typically not by freshest thread including all replies, but
by freshest start date of a thread. This could be changed by adding a
column to record touch-date.
Ordering is typically not by freshest thread including all replies, but
by freshest start date of a thread. This could be changed by adding a
column to record touch-date.
HTH
Are you saying this re: the plugin or forums in general?
I’m looking at the plugin, it looks like it will not accomplish my ends.
I’m thinking I will have to create my own method(s) to get this to work.
I’ve seen forums work without having a column for the last date
accessed. I guess a part of me feels I shouldn’t have to create a
column like that when such information can be derived by other aspects
of the database.