I am VERY new to the RoR game, but quickly becoming a convert. I am doing a discussion board application in RoR just to learn RoR. You all are very familiar with the discussion board domain. Someone starts a new thread, someone comments on that thread and or starts a new thread and so on... I have a table called comments. This table follows all the Railisms but I have a few questions. What would I call a field in the comments table that refers BACK to itself (ie the comments table)? This is for child comments. This would maintain a child/parent relationship for each of the comments. Then would I add belongs_to :comment has_many :comments in the comments.rb Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I would highly recommend going through the AWDwRv2 before embarking on your application. This would help you get the necessary foundation to begin rails development. Anyway, the term or phrase that you''re looking for is called a self referential relationship. Good luck, -Conrad On 2/24/07, dougd1101 <dougd1101-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am VERY new to the RoR game, but quickly becoming a convert. > > I am doing a discussion board application in RoR just to learn RoR. > You all are very familiar with the discussion board domain. Someone > starts a new thread, someone comments on that thread and or starts a > new thread and so on... > > I have a table called comments. This table follows all the Railisms > but I have a few questions. What would I call a field in the comments > table that refers BACK to itself (ie the comments table)? This is for > child comments. This would maintain a child/parent relationship for > each of the comments. > > Then would I add > belongs_to :comment > has_many :comments > > in the comments.rb > > > Thanks. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 2/25/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, I would highly recommend going through the AWDwRv2 before > embarking on your application. This would help you get the necessary > foundation to begin rails development. Anyway, the term or phrase > that you''re looking for is called a self referential relationship. > > Good luck, > > -ConradAnd the specific column you''re looking for is called comment_id (you can actually name it anything you want via the :foreign_key => ''some_other_column_name_here'', but the default is comment_id) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---