简体   繁体   中英

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 (eg 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 structure 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM