# Threaded forum

**URL:** <https://www.ruby-forum.com/t/threaded-forum/90027>\
**Category:** Rails\
**Created:** [March 25, 2007, 6:20am UTC](https://www.ruby-forum.com/t/threaded-forum/90027 "2007-03-25T06:20:47Z")\
**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:** [March 25, 2007, 6:20am UTC](https://www.ruby-forum.com/t/threaded-forum/90027/1 "2007-03-25T06:20:47Z")

</div>

I’m having trouble sensibly designing a forum-type application with real  
threads. Whereas most forums have flat threads, my threads are actually  
“threaded” if you get what I mean, ie they are displayed in a fashion  
such as

Post  
-Reply  
–Reply

and so on.

So my first attempt was to use acts\_as\_tree. Unfortunately I found it  
impossible to grab an entire thread with this. I could grab one post  
and its immediate children, but I couldn’t grab those children’s  
children without more queries for each depth level. Depending on the  
depth of a thread, massive amounts of queries could be run because of  
this.

I later learned about acts\_as\_nested\_set, which seemed like a better  
solution. It has a method #all\_children which would effectively grab  
all the children - regardless of depth - of an object. I thought this  
would work, but acts\_as\_nested\_set seems underpowered. For example,  
with acts\_as\_tree I can do post.root and I will get the post at the very  
top of the tree. For some reason acts\_as\_nested\_set doesn’t have this,  
and I need this feature for a reason: i want to bump a thread when it  
has been replied to, but I can’t effectively change the bumped\_on  
timestamp of the root of the thread without being able to effectively  
find the root.

My only other hope was acts\_as\_threaded, which is a plugin supposedly  
designed for threads. Unfortunately the site on which the plugin is  
located has been down for a few days and for some reason I doubt it will  
be back up.

So I’m kind of out of ideas here. I mean the threaded forum paradigm is  
pretty old, so there must be a sensible design pattern for this. I just  
don’t know what it is.

---

<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:** [March 25, 2007, 8:24pm UTC](https://www.ruby-forum.com/t/threaded-forum/90027/2 "2007-03-25T20:24:18Z")

</div>

Eleo,  
I’m having the same issue. I’d love to see some OSS project that’s  
implemented threaded comments, but so far haven’t found anything.  
[Chowhound.com](http://Chowhound.com) which is Rails is the perfect example of what I’d like to  
do.

here’s a mirror of acts\_as\_threaded:  
[http://marcusvorwaller.com/acts\_as\_threaded.zip](http://marcusvorwaller.com/acts_as_threaded.zip)

-Marcus

Eleo wrote:

> I’m having trouble sensibly designing a forum-type application with real  
> threads. Whereas most forums have flat threads, my threads are actually  
> “threaded” if you get what I mean, ie they are displayed in a fashion  
> such as
> 
> Post  
> -Reply  
> –Reply
> 
> and so on.
> 
> So my first attempt was to use acts\_as\_tree. Unfortunately I found it  
> impossible to grab an entire thread with this. I could grab one post  
> and its immediate children, but I couldn’t grab those children’s  
> children without more queries for each depth level. Depending on the  
> depth of a thread, massive amounts of queries could be run because of  
> this.
> 
> I later learned about acts\_as\_nested\_set, which seemed like a better  
> solution. It has a method #all\_children which would effectively grab  
> all the children - regardless of depth - of an object. I thought this  
> would work, but acts\_as\_nested\_set seems underpowered. For example,  
> with acts\_as\_tree I can do post.root and I will get the post at the very  
> top of the tree. For some reason acts\_as\_nested\_set doesn’t have this,  
> and I need this feature for a reason: i want to bump a thread when it  
> has been replied to, but I can’t effectively change the bumped\_on  
> timestamp of the root of the thread without being able to effectively  
> find the root.
> 
> My only other hope was acts\_as\_threaded, which is a plugin supposedly  
> designed for threads. Unfortunately the site on which the plugin is  
> located has been down for a few days and for some reason I doubt it will  
> be back up.
> 
> So I’m kind of out of ideas here. I mean the threaded forum paradigm is  
> pretty old, so there must be a sensible design pattern for this. I just  
> don’t know what it is.

---

<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:** [March 25, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/threaded-forum/90027/3 "2007-03-25T20:39:58Z")

</div>

Thanks for the acts\_as\_threaded mirror.

Last night I discovered “better nested set” which adds useful functions  
to acts\_as\_nested\_set. For example you can do object.root and so on. I  
have yet to test it out, though.

---

<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:** [March 25, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/threaded-forum/90027/4 "2007-03-25T20:52:08Z")

</div>

Eleo wrote:

> Googlable but I should have left a link out of courtesy:
> 
> [http://opensource.symetrie.com/trac/better\_nested\_set/](http://opensource.symetrie.com/trac/better_nested_set/)
> 
> And yeah, the example you provided is basically -exactly- what I’m  
> trying to achieve, right down to the AJAX comment box appearing  
> underneath the post one is trying to reply to.

Chowhound is also googlable but it’s by PJ Hyett and Chris W. who  
have one of the (IMHO) best Rails blogs out there. Here’s a particularly  
useful post:

> **[Me and uFormats — err.the\_blog](http://errtheblog.com/post/35)**
>
> Err the Blog: Ruby and Rails from the front.

---

<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:** [March 25, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/threaded-forum/90027/5 "2007-03-25T20:47:33Z")

</div>

Googlable but I should have left a link out of courtesy:

[http://opensource.symetrie.com/trac/better\_nested\_set/](http://opensource.symetrie.com/trac/better_nested_set/)

And yeah, the example you provided is basically -exactly- what I’m  
trying to achieve, right down to the AJAX comment box appearing  
underneath the post one is trying to reply to.

---

<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:** [March 25, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/threaded-forum/90027/6 "2007-03-25T22:18:09Z")

</div>

I’m wondering, if you have acts\_as\_threaded, how come you’re still  
unable to implement threaded comments? Is the plugin inadequate?
