lib/ask/acts_as_answerer.rb in ask-0.2.0 vs lib/ask/acts_as_answerer.rb in ask-0.3.0
- old
+ new
@@ -18,9 +18,28 @@
else
all_questions.find_by_name(question.to_s)
end
end
+ def questions_by_section
+ section = nil
+ questions = {}
+
+ asker.questions.order(:position).each do |question|
+ if question.is_a? FormSection
+ section = question
+ end
+
+ questions[section] ||= []
+
+ unless question.is_a? FormSection
+ questions[section] << question
+ end
+ end
+
+ questions
+ end
+
def answer_to(question)
return nil if question.nil?
if question.supports_multiple_answers?
answers_to(question)
else