# RoR Forum Application

**URL:** <https://www.ruby-forum.com/t/ror-forum-application/107556>\
**Category:** Rails\
**Created:** [June 23, 2007, 3:50am UTC](https://www.ruby-forum.com/t/ror-forum-application/107556 "2007-06-23T03:50:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 23, 2007, 3:50am UTC](https://www.ruby-forum.com/t/ror-forum-application/107556/1 "2007-06-23T03:50:51Z")

</div>

Hello,

```
 I am working on a Ruby on Rails application that will have a forum

```

and am looking for some guidance. I am currently able to add topics to  
forum sections or groups. Where I am struggling is to in the ability to  
reply or continue a topic. I notice from searching on the internet that  
others use a topic\_id. Obviously, this would keep the topics unique. I  
have figured out that when replying to the topic I could get the  
topic\_id from the db and have it inserted back into the db when the  
reply is submitted. This would link the original post to the reply.  
Where I am not sure is creating the topic\_id initially. If I have  
multiple topics have been replied to and the database table has an  
unordered list of topic ids, how would I make sure that the new topic id  
would not cause a conflict? In other words if I had:

testing topic topic\_id\_1  
test topic topic\_id\_2  
testing topic topic\_id\_1  
test topic topic\_id\_2  
testing topic topic\_id\_1

If I query the db to get the next topic id and get the last record it  
would say the next topic id should be 2 which is incorrect. Should I  
use find and set my order like this:

:order =\> “topic\_id DESC” and just add 1 to it? Is there a better (as  
in efficient) way?

thanks for any insight.  
Mike

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 23, 2007, 4:35am UTC](https://www.ruby-forum.com/t/ror-forum-application/107556/2 "2007-06-23T04:35:21Z")

</div>

Do you have posts that belong\_to topics?

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 24, 2007, 12:54am UTC](https://www.ruby-forum.com/t/ror-forum-application/107556/3 "2007-06-24T00:54:12Z")

</div>

Carl J. wrote:

> Do you have posts that belong\_to topics?

Carl,

```
 Sorry for the late reply. I haven't as of yet set up any 

```

associations. My models are set up as:

groups (store forum sections or groups)  
groupmessages (store messages specific to each groups)

Should I be more specific with my models? What is considered best  
practices in RoR for specifying models?

thanks.  
Mike R.

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 24, 2007, 4:04am UTC](https://www.ruby-forum.com/t/ror-forum-application/107556/4 "2007-06-24T04:04:58Z")

</div>

Mike R. wrote:

> Should I be more specific with my models? What is considered best  
> practices in RoR for specifying models?

I highly recommend you read “Agile Web D. with Rails” or a  
similar Rails book.
