Created
January 24, 2014 08:45
-
-
Save goomerko/8594062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def edit | |
# Find or create all the answers needed for the selected options | |
used_option_answers = [] | |
@participate.options.each do |option| | |
option.option_questions.each do |option_question| | |
unless @participate.option_answers.where(option_question_id: option_question.id).first | |
# If the answer doesn't exist then create it | |
option_answer = OptionAnswer.new(option_question_id: option_question.id, subscription_id: @participate.id) | |
# we need to bypass the answer validation | |
option_answer.save(validate: false) | |
@participate.option_answers << option_answer | |
used_option_answers << option_answer | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment