From f0c0bd848684bfc730f6d6207a8477bf63c2b43f Mon Sep 17 00:00:00 2001 From: CoralineAda Date: Fri, 30 Aug 2024 19:48:39 -0500 Subject: [PATCH] Move the nil exclusion to the query --- app/controllers/questions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index be71749..9c25606 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -2,7 +2,7 @@ class QuestionsController < ApplicationController def show @question = Question.from(params[:id]) - @responses = SurveyResponse.all.order(:created_at).reject{|sr| sr.read_attribute(@question.key).nil? } + @responses = SurveyResponse.where("#{@question.key} IS NOT NULL").order(:created_at) end end