Created
October 16, 2008 20:56
-
-
Save paul/17260 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
# I have a set of questions, each of which have a default (default_answers) | |
# I also have a set of answers for questions, but not every question (answers) | |
# I want an array of every answer, priority to the actual answers, but filling | |
# in the default answer when no actual answer exists. | |
def all_answers | |
all_answers = {} | |
default_answers.each do |answer| | |
all_answers[answer.question_name] == answer | |
end | |
answers.each do |answer| | |
all_answers[answer.question_name] == answer | |
end | |
all_answers.values | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment