RoR Forum Application

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

Do you have posts that belong_to topics?

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs