Ralph Wood
2008-Nov-27 11:59 UTC
A topic on a category of a subforum really belongs_to what?
Suppose you have a forum with many sub-forums, and each sub-forum has many categories (or sub-sub-forums), and each category may or may not have many sub-categories (or sub-sub-sub-forums). Will a topic belong to the sub-category AND category AND sub-forum; or only to a sub-category, that will in turn belong to a category that will in turn belong to a sub-forum? -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Nov-27 12:59 UTC
Re: A topic on a category of a subforum really belongs_to what?
In parts this may depend on the table structure. I would avoid having too much tables here (forum + category) and if possible go for a single table. But in general avoid duplicate data. If a topic is linked to a sub category and this sub category is already linked to a category, there is not much need in adding another field to the topic. That would just bring the risk, that the data gets inconsistent if you need to relink the subforum structure. You should provide a function that for a given forum gets the ids of all subforums (including sub sub forums, categories...) and then get all the topics linked with those forum ids --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Klaus Pieslinger
2008-Nov-27 20:53 UTC
Re: A topic on a category of a subforum really belongs_to what?
I''d go for self-referencing Forum and Category, to allow for children / grand / etc in the same tables. After that, where the Topic belongs to is a matter of how do you traverse the tree. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ralph Wood
2008-Nov-27 22:54 UTC
Re: A topic on a category of a subforum really belongs_to what?
@Thorsten — I had figured that as well, so I went looking for info on that and found out about this neat "model:references" bit you can include in the script/generate. @Klaus — Could you demonstrate? For example, I was reading a tutorial earlier in which the author demonstrated that you can make a Forum "has_many :posts, :through => :topics", but you can''t make it "has_many :users, :through => :posts", because the relationship won''t go that deep. So I wonder if it''s even possible for a Forum to have sub-categories through categories through sub-forums. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---