I have an interesting puzzle I've been trying to find a more elegant solution.
I have 2 models. Surveys
and Questions
which are connect in a has_many through relation by QuestionLogs
. has_many :questions, :through => :question_logs
This works fine, my problem is I have the need for variant Surveys. eg. I may have 3 Surveys which are made for different regions, say Chicago, LA, and Austin. They share 90% of the questions in common, but may substitute one or two questions.
At the moment, I start with one Survey, (with a unique sid scoped by region_id), Survey A and when it's complete I create a duplicate Survey B, (same sid, different region_id) which creates 10 new QuestionLogs to those exact same questions, and I then substitute 1 or 2 questions depending on the region. (e.g. if I have a survey with 2 variants, with 10 questions, i end up with 30 QuestionLogs to those same questions which are nearly identical).
This works fine. My question is if there's an alternative way to avoid this duplication of QuestionLogs. For example, a way to handle variations of a model and it's dependents, recording differences, rather than simple duplication.
FYI, each survey has exactly 10 questions, the questions are created separately before the survey, and the model is quite complex, eg. it has answers, etc.
Any suggestions or direction would be greatly appreciated, thanks!