diff --git a/app/views/admin/questions/show.html.haml b/app/views/admin/questions/show.html.haml index c80c6e68..36c003bc 100644 --- a/app/views/admin/questions/show.html.haml +++ b/app/views/admin/questions/show.html.haml @@ -5,7 +5,7 @@ %h1= @question.title - @question.answers.each do |answer| = answer.title - (#{answer.qanswers.find_by(question: @question).registrations.where(conference: @conference).count}) + (#{answer.qanswers.find_by(question: @question)&.registrations&.where(conference: @conference)&.count || 0}) .row diff --git a/app/views/admin/registrations/index.pdf.prawn b/app/views/admin/registrations/index.pdf.prawn index 3edebf04..169b5514 100644 --- a/app/views/admin/registrations/index.pdf.prawn +++ b/app/views/admin/registrations/index.pdf.prawn @@ -20,7 +20,7 @@ prawn_document(force_download: true, filename: @pdf_filename, page_layout: :land @conference.questions.each do |question| qa = registration.qanswers.find_by(question: question) - answer = ( qa ? qa.answer.title : '' ) + answer = qa&.answer&.title || '' row << answer end diff --git a/app/views/admin/registrations/index.xlsx.axlsx b/app/views/admin/registrations/index.xlsx.axlsx index 596d9fd2..c92e84fd 100644 --- a/app/views/admin/registrations/index.xlsx.axlsx +++ b/app/views/admin/registrations/index.xlsx.axlsx @@ -21,7 +21,7 @@ wb.add_worksheet(name: 'registrations') do |sheet| row << registration.user.physical_tickets.by_conference(@conference).first&.token @conference.questions.each do |question| qa = registration.qanswers.find_by(question: question) - answer = ( qa ? qa.answer.title : '' ) + answer = qa&.answer&.title || '' row << answer end