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