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) })
This commit is contained in:
Espartaco Palma 2020-01-21 00:49:45 -08:00 committed by Henne Vogelsang
parent f50a92bf53
commit 490ea3c4b4
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0

View file

@ -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