survey/app/models/survey_answer_group.rb

13 lines
380 B
Ruby

class SurveyAnswerGroup
include Mongoid::Document
field :user, type: BSON::ObjectId
field :survey_answer_ids, type: Array, default: []
field :last_modified, type: Time, default: Time.now
belongs_to :questionnaire_survey
def survey_answers
SurveyAnswer.where(:id.in=>survey_answer_ids)
end
after_destroy do
SurveyAnswer.where(:id.in=>survey_answer_ids).destroy
end
end