David Johnson
2006-Mar-09 04:33 UTC
[Rails] Newbie question: How to represent parent-child denormalization
I am building a relatively trivial application to try to learn my way around Rails. I am having difficulty understanding how to navigate a heavily denormalized hierarchy. Could someone direct me to a bare-bones explanation of using rails to navigate database hierarchies? I am an experienced developer. Most of my work has been desktop client server, high performance, or server to server interprocess work in large scale systems (8K plus users). However, I am new to Ruby and the rails environment. Furthermore, I have never been comfortable with html development. My idea of a perfect screen is plain white that is sparsely populated with black text with a single font and no effects. The default stylesheets that rails generates are quite a bit more elaborate than I would choose to build :o) I am trying to build a flash-card application that contains quizzes, questions, possible answers, and presentations, plus historical records of users''s answers over time (quiz_instances, question_instances, response_instances). I have been working from Thomas and Hansson (Agile Web Development With Rails), but I appear to be missing something in the move from the famous "depot" example into real life. I cannot for the life of me figure out how to navigate from parent objects (such as a quiz) to child objects. I find a lot of what I generally consider "fluff" - adding pictures and fonts, and tweaking positions on the screen, but I am not finding how to build controls to navigate a hierarchy. I could either be having issues with some web development fundamental, or my own misunderstanding of how Rails is supposed to work. What I have now is a skeleton that allows me to create, edit, and destroy quizzes. I have created the question controller, model, and views. However, I can''t seem to be able to redirect to the list of questions from the quiz controller. I think I understand how to nest lists once I understand how to navigate a hierarchy. Since questions have no content of their own, I will also need to navigate to the presentation level to get the actual text for the question. This is a simple hierarchical structure, with the only twist being that a presentation (text, audio, and graphic) may be owned by either a quiz (preamble and postamble), a question (preamble, body, postamble), or a possible answer (body). This chart may make it more clear (or not): (quiz) 1..n (question) 1..n (possible answer) 1..n (presentation) (question.preamble) 1..1 (presentation) (question.body) 1..1 (presentation) (question.postamble) 1..1 (presentation) (quiz.preamble) 1..1 (presentation) (quiz.postamble) 1..1 (presentation) At present, I have defined quiz and question. I believe that once I have these under control I will be able to move forward. Thanks in advance. David Johnson
M Daggett
2006-Mar-09 17:32 UTC
[Rails] Newbie question: How to represent parent-child denormalization
Hi David, you may want to look into the acts_as_tree structure On 3/8/06, David Johnson <johnson_d@cox.net> wrote:> > I am building a relatively trivial application to try to learn my way > around Rails. I am having difficulty understanding how to navigate a > heavily denormalized hierarchy. Could someone direct me to a bare-bones > explanation of using rails to navigate database hierarchies? > > I am an experienced developer. Most of my work has been desktop client > server, high performance, or server to server interprocess work in large > scale systems (8K plus users). > > However, I am new to Ruby and the rails environment. Furthermore, I > have never been comfortable with html development. My idea of a perfect > screen is plain white that is sparsely populated with black text with a > single font and no effects. The default stylesheets that rails > generates are quite a bit more elaborate than I would choose to > build :o) > > I am trying to build a flash-card application that contains quizzes, > questions, possible answers, and presentations, plus historical records > of users''s answers over time (quiz_instances, question_instances, > response_instances). > > I have been working from Thomas and Hansson (Agile Web Development With > Rails), but I appear to be missing something in the move from the famous > "depot" example into real life. I cannot for the life of me figure out > how to navigate from parent objects (such as a quiz) to child objects. > I find a lot of what I generally consider "fluff" - adding pictures and > fonts, and tweaking positions on the screen, but I am not finding how to > build controls to navigate a hierarchy. > > I could either be having issues with some web development fundamental, > or my own misunderstanding of how Rails is supposed to work. > > What I have now is a skeleton that allows me to create, edit, and > destroy quizzes. > > I have created the question controller, model, and views. However, I > can''t seem to be able to redirect to the list of questions from the quiz > controller. I think I understand how to nest lists once I understand > how to navigate a hierarchy. > > Since questions have no content of their own, I will also need to > navigate to the presentation level to get the actual text for the > question. This is a simple hierarchical structure, with the only twist > being that a presentation (text, audio, and graphic) may be owned by > either a quiz (preamble and postamble), a question (preamble, body, > postamble), or a possible answer (body). > > This chart may make it more clear (or not): > > (quiz) 1..n (question) 1..n (possible answer) 1..n (presentation) > (question.preamble) 1..1 (presentation) > (question.body) 1..1 (presentation) > (question.postamble) 1..1 (presentation) > (quiz.preamble) 1..1 (presentation) > (quiz.postamble) 1..1 (presentation) > > At present, I have defined quiz and question. I believe that once I > have these under control I will be able to move forward. > > Thanks in advance. > David Johnson > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -------------------------------------------------------------------- I am Mark Daggett and I approve this message. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060309/7fdadbfa/attachment.html