Hi, I want to create web application where people can discuss some things. There will be a Posts and users can comment it, but I also want users can comment commentaries. Can I create model comment, that belongs_to comment and has_many comments, or smth similar? I only studying Rails. Sorry for my bad english. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/sy6A-bySYfwJ. For more options, visit https://groups.google.com/groups/opt_out.
On 17 January 2013 18:32, Роман Пружанский <19prv94-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I want to create web application where people can discuss some things. > There will be a Posts and users can comment it, but I also want users can > comment commentaries. > Can I create model comment, that belongs_to comment and has_many comments, > or smth similar?Start by working through the tutorial at railstutorial.org. That will give you a good understanding of the basics of rails. Also look at the Rails Guides. When working through any tutorial make sure that the tutorial is for rails 3 and that you have installed exactly the rails version that the tutorial expects. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jan 17, 2013, at 1:32 PM, Роман Пружанский wrote:> Hi, > > I want to create web application where people can discuss some things. > There will be a Posts and users can comment it, but I also want users can comment commentaries. > Can I create model comment, that belongs_to comment and has_many comments, or smth similar? > > I only studying Rails. Sorry for my bad english.You may want to look at Single Table Inheritance for this. That''s a pretty simple way to make a linked list, which is what you''re describing. Walter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 17 January 2013 21:51, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> > On Jan 17, 2013, at 1:32 PM, Роман Пружанский wrote: > >> Hi, >> >> I want to create web application where people can discuss some things. >> There will be a Posts and users can comment it, but I also want users can comment commentaries. >> Can I create model comment, that belongs_to comment and has_many comments, or smth similar? >> >> I only studying Rails. Sorry for my bad english. > > You may want to look at Single Table Inheritance for this. That''s a pretty simple way to make a linked list, which is what you''re describing.Walter, can you give a link or a brief description on how to use STI to implement a linked list, or a link to a description? I have not come across that idea before. thanks Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jan 17, 2013, at 5:01 PM, Colin Law wrote:> On 17 January 2013 21:51, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: >> >> On Jan 17, 2013, at 1:32 PM, Роман Пружанский wrote: >> >>> Hi, >>> >>> I want to create web application where people can discuss some things. >>> There will be a Posts and users can comment it, but I also want users can comment commentaries. >>> Can I create model comment, that belongs_to comment and has_many comments, or smth similar? >>> >>> I only studying Rails. Sorry for my bad english. >> >> You may want to look at Single Table Inheritance for this. That''s a pretty simple way to make a linked list, which is what you''re describing. > > Walter, can you give a link or a brief description on how to use STI > to implement a linked list, or a link to a description? I have not > come across that idea before.I am pretty sure I am mis-remembering the name of the thing. The more I look at it, the more wrong I think I am here. Sorry for the noise. I''ll try to remember what I was thinking of here... Walter> > thanks > > Colin > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jan 17, 2013, at 5:31 PM, Walter Lee Davis wrote:> > On Jan 17, 2013, at 5:01 PM, Colin Law wrote: > >> On 17 January 2013 21:51, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: >>> >>> On Jan 17, 2013, at 1:32 PM, Роман Пружанский wrote: >>> >>>> Hi, >>>> >>>> I want to create web application where people can discuss some things. >>>> There will be a Posts and users can comment it, but I also want users can comment commentaries. >>>> Can I create model comment, that belongs_to comment and has_many comments, or smth similar? >>>> >>>> I only studying Rails. Sorry for my bad english. >>> >>> You may want to look at Single Table Inheritance for this. That''s a pretty simple way to make a linked list, which is what you''re describing. >> >> Walter, can you give a link or a brief description on how to use STI >> to implement a linked list, or a link to a description? I have not >> come across that idea before. > > I am pretty sure I am mis-remembering the name of the thing. The more I look at it, the more wrong I think I am here. > > Sorry for the noise. I''ll try to remember what I was thinking of here...Maybe this: https://github.com/stefankroes/ancestry Not a linked list, but something called a "materialized path". I figured out why I was thinking STI -- I made a forum years ago that had Threads and Comments, organized in an STI table. There was only one layer of inheritance, not what the OP was asking for. If you were only ever looking at a chronological list of comments, you could have a :parent attribute that was a self-reference to another record in the same table. That could give you your nesting structure, simply by looking up the chain of ancestors to the root. Walter> > Walter > >> >> thanks >> >> Colin >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 17 January 2013 18:32, Роман Пружанский <19prv94-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I want to create web application where people can discuss some things. > There will be a Posts and users can comment it, but I also want users can > comment commentaries. > Can I create model comment, that belongs_to comment and has_many comments, > or smth similar?I think what you are looking for is a self referential model. If you google for rails self referential you will find suggestions on how to do it. Start with some of the later links however as the details of rails has changed over the years. The basic principle is still the same though. My earlier suggestion of working through tutorials to get the basics still stands however, if you have not already done that. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.