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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Do you have posts that belong_to topics? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Carl Johnson 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 Riley -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Riley 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 Development with Rails" or a similar Rails book. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---