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? -- Posted via http://www.ruby-forum.com/.
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. -- Posted via http://www.ruby-forum.com/.
Look at acts_as_threaded. http://www.railtie.net/articles/2006/02/05/rails-acts_as_threaded-plugin 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. HTH On Friday, May 12, 2006, at 11:50 PM, Eleo wrote:>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? > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your mailbox.
steve ross wrote:> 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. > > HTHAre you saying this re: the plugin or forums in general? -- Posted via http://www.ruby-forum.com/.
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. Is my approach flawed in this repect? -- Posted via http://www.ruby-forum.com/.
Re the plugin. My understanding is that ordering is typically done --with this plugin-- by the order of the thread root. On Saturday, May 13, 2006, at 1:34 AM, Eleo wrote:>steve ross wrote: >> 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? > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your mailbox.