Method: Ask::ActiveRecord::InstanceMethods#questions_with_answers

Defined in:
lib/ask/acts_as_answerer.rb

#questions_with_answersObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ask/acts_as_answerer.rb', line 71

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.id] = []
  end

  answers.each do |a|
    qa[a.question.id] << a.answer.to_s.strip unless a.answer.blank?
  end

  qa
end