# Bumping threads in a forum-type app

**URL:** <https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390>\
**Category:** Rails\
**Created:** [May 12, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390 "2006-05-12T23:50:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 12, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/1 "2006-05-12T23:50:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 13, 2006, 12:29am UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/2 "2006-05-13T00:29:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 13, 2006, 1:01am UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/3 "2006-05-13T01:01:29Z")

</div>

Look at acts\_as\_threaded.

[http://www.railtie.net/articles/2006/02/05/rails-acts\_as\_threaded-plugin](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

---

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 13, 2006, 1:34am UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/4 "2006-05-13T01:34:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 13, 2006, 3:14am UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/5 "2006-05-13T03:14:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![eleo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea5d25/32.png) [@eleo](https://www.ruby-forum.com/u/eleo)\
**Post date:** [May 13, 2006, 8:55am UTC](https://www.ruby-forum.com/t/bumping-threads-in-a-forum-type-app/60390/6 "2006-05-13T08:55:19Z")

</div>

Re the plugin. My understanding is that ordering is typically done  
–with this plugin-- by the order of the thread root.
