fix access denied error for program in custom domains

This commit is contained in:
shlok007 2017-07-25 07:42:50 +05:30 committed by Shlok Srivastava
parent 0ac5d18ef2
commit f4775f8e6a

View file

@ -2,7 +2,6 @@ class ConferencesController < ApplicationController
protect_from_forgery with: :null_session protect_from_forgery with: :null_session
before_action :respond_to_options before_action :respond_to_options
load_and_authorize_resource find_by: :short_title load_and_authorize_resource find_by: :short_title
load_resource :program, through: :conference, singleton: true, except: :index
def index def index
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc) @current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
@ -10,14 +9,15 @@ class ConferencesController < ApplicationController
end end
def show def show
# have to change "localhost" to ENV['OSEM_HOSTNAME'] in production # have to change "localhost" to ENV['OSEM_HOSTNAME'] in production
check_custom_domain if request.host != 'localhost' check_custom_domain if request.host != 'localhost'
@program = @conference.program
end end
private private
def check_custom_domain def check_custom_domain
@conference = @conference.custom_domain.present? ? Conference.find_by(custom_domain: request.domain) : @conference @conference = @conference.nil? ? Conference.find_by(custom_domain: request.domain) : @conference
end end
def respond_to_options def respond_to_options