From 0e8e626156683dfd11779f8659d6f92c3b09e1e9 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Fri, 24 Mar 2017 20:52:27 +0530 Subject: [PATCH] Allow to view schedule without login Add show and events action's can abilities of schedule for not_signed_in user in order to make schedule available to view without login. Closes #1343 --- app/controllers/schedules_controller.rb | 3 ++- app/models/ability.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 0b135328..e0d1e1ca 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -1,7 +1,8 @@ class SchedulesController < ApplicationController + load_and_authorize_resource protect_from_forgery with: :null_session before_action :respond_to_options - load_and_authorize_resource :conference, find_by: :short_title + load_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true, except: :index def show diff --git a/app/models/ability.rb b/app/models/ability.rb index ce047a1b..14913e75 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -62,6 +62,10 @@ class Ability can [:new, :create], Event do |event| event.program.cfp_open? && event.new_record? end + + can [:show, :events], Schedule do |schedule| + schedule.program.schedule_public + end end end