From 27d56ad104001e1ffe90d6cf8ffba1ba495d8562 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 11 Sep 2017 17:47:14 +0200 Subject: [PATCH] Refactor officing polls #final method to be cleaner --- app/controllers/officing/polls_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/officing/polls_controller.rb b/app/controllers/officing/polls_controller.rb index e122284ec..ba2a5c01a 100644 --- a/app/controllers/officing/polls_controller.rb +++ b/app/controllers/officing/polls_controller.rb @@ -6,10 +6,11 @@ class Officing::PollsController < Officing::BaseController end def final - @polls = current_user.poll_officer? ? current_user.poll_officer.final_days_assigned_polls : [] - return unless current_user.poll_officer? - - @polls = @polls.select {|poll| poll.ends_at > 1.week.ago && poll.expired?} + @polls = if current_user.poll_officer? + current_user.poll_officer.final_days_assigned_polls.select {|poll| poll.ends_at > 1.week.ago && poll.expired?} + else + [] + end end -end \ No newline at end of file +end