lib/ask/acts_as_answerer.rb in ask-0.4.1 vs lib/ask/acts_as_answerer.rb in ask-0.5.0
- old
+ new
@@ -74,24 +74,25 @@
def questions_with_answers
qa = ActiveSupport::OrderedHash.new
# Set the correct order and make sure we have all the questions
all_questions.each do |q|
- qa[q.name] = []
+ qa[q.id] = []
end
answers.each do |a|
- qa[a.question.name] << a.answer.to_s.strip unless a.answer.blank?
+ qa[a.question.id] << a.answer.to_s.strip unless a.answer.blank?
end
qa
end
private
def validate_required_questions
+ return if asker.blank?
asker.questions.required.each do |question|
- if answers.select{|a| a.question_id == question.id}.all?{|a| a.answer.blank?}
+ if answers.select{|a| a.question_id == question.id}.all?{|a| a.fails_required?}
errors[:base] << "\"#{question.name}\" is required"
end
end
end
end