Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

Rails Survey App Data Structure

I'm pretty new to rails and have just begun playing around with creating a rails survey app to help better understand a nested data structure. I know I'm going to configure it so that a Survey has_many Questions. What I'm wondering is should I create another object "Answer" to just store each answer response and say a Question has_many Answers? Or should I just look into storing that information into the Question objects themselves? Really the only content that an answer will have is it's name.

I guess I'm looking for recommendations for how to handle this type of nested data structure.

Also, I haven't given too much though with how I would store responses - would having Answers as separate objects be easier to store/display the outcome of the survey?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

May be this structure will be useful for you

  1. survey
  2. survey_question, have a foreign of survey
  3. survey_choice, have a foreign of survey question
  4. survey_vote, have foreign of user who is voting and choice id which he will select.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...