How to structure Ruby on Rails app?
I'd like to build a simple survey/questionnaire app in Ruby on Rails and wanted to make sure I have the "general" structure correct. The application should allow an administrator to create a new survey and populate it with questions. The answers should pre-populate from a list in the database (e.g. none, a little, somewhat, often, frequently, etc.). Users should then be able to login, select a survey, and complete the questions/answers with their results being stored in a DB.
I've worked out the following scaffolded structu开发者_如何学编程re which I will later refactor:
-User -Survey (has_many Questions) --Question (belongs_to Survey, has_many Answers) --Answer_Option (belongs_to Survey) ---Answer (belongs_to Question)
Is that general format correct? I feel like I'm missing something -- perhaps a join table to generate the results? Any thoughts from someone smarter than me? Thanks :)
One thing to consider is, if you really want to re-enter the Answer_Options for every survey. I'd go with a general Answer_Option
(or Question_Type
) that can be re-used, maybe adding the possibility to create user-generated answer options on the fly.
精彩评论