From 490ea3c4b423ce01e099b57fe912bf0b76814f13 Mon Sep 17 00:00:00 2001 From: Espartaco Palma Date: Tue, 21 Jan 2020 00:49:45 -0800 Subject: [PATCH] DRY on controllers/conferences_controller Conferences.incoming is defined on the model as scope: scope :upcoming, (-> { where('end_date >= ?', Date.current) }) Conference.past scope :past, (-> { where('end_date < ?', Date.current) }) --- app/controllers/conferences_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 3878481b..90d1274b 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -6,8 +6,8 @@ class ConferencesController < ApplicationController load_and_authorize_resource find_by: :short_title, except: :show def index - @current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc) - @antiquated = Conference.where('end_date < ?', Date.current) + @current = Conference.upcoming.reorder(start_date: :asc) + @antiquated = Conference.past if @antiquated.empty? && @current.empty? && User.empty? render :new_install end