Rails newbie having a question about storing the order of associations. Background is I'm thinking about building a super simple survey app for learning purposes. The idea is to have multiple surveys and corresponding questions.
Models are straightforward:
class Survey
has_many :questions
end
class Question
belongs_to :survey
end
My question now - where and how would you store the custom order / sequence of the questions in the survey? Questions may be moved around, added and removed and should retain answers from survey responses.
I was thinking about introducing a "rank_id" (inside the question or survey model?), or some kind of new question_list model (survey has_one :question_list, has_many :questions through :question_list
). But even with the question_list model, I don't really know how to retain order. Googling led me to Saving the order of associated records in a Rails has_many :through association
and it recommends the acts_as_list gem, but that seems like too much for this use case?
Thanks in advance for any suggestions!