This commit is contained in:
Divyanshu Mehta 2017-07-04 08:08:55 +00:00 committed by GitHub
commit 4a624f10eb
6 changed files with 73 additions and 3 deletions

View file

@ -2,7 +2,7 @@ class ConferencesController < ApplicationController
protect_from_forgery with: :null_session
before_action :respond_to_options
load_and_authorize_resource find_by: :short_title
load_resource :program, through: :conference, singleton: true, except: :index
load_resource :program, through: :conference, singleton: true, except: [:index, :current]
def index
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
@ -11,6 +11,12 @@ class ConferencesController < ApplicationController
def show; end
def current
current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current).first
current = Conference.where('start_date = ?', Date.current + 1).first if current.blank?
redirect_to conference_path(current.short_title)
end
private
def respond_to_options

View file

@ -29,7 +29,7 @@ class Ability
# Abilities for not signed in users (guests)
def not_signed_in
can [:index], Conference
can [:index, :current], Conference
can [:show], Conference do |conference|
conference.splashpage && conference.splashpage.public == true
end