diff --git a/app/controllers/application_controller/with_university.rb b/app/controllers/application_controller/with_university.rb index 8e9b06f0b33fbc5b70820edc901947526031f329..6fa37e2878780bede8d647ca08200a701b0ea6a1 100644 --- a/app/controllers/application_controller/with_university.rb +++ b/app/controllers/application_controller/with_university.rb @@ -2,6 +2,7 @@ module ApplicationController::WithUniversity extend ActiveSupport::Concern included do + # Raises ActiveRecord::RecordNotFound to prevent access from non-listed hosts def current_university @current_university ||= University.with_host(request.host) end diff --git a/app/models/university/with_identifier.rb b/app/models/university/with_identifier.rb index 5ed1c31a663cb43c418d6bcd82932a35e695c559..f11d17f1aa274493d15a5e27c5934b0f14702aca 100644 --- a/app/models/university/with_identifier.rb +++ b/app/models/university/with_identifier.rb @@ -14,7 +14,7 @@ module University::WithIdentifier end def self.with_host(host) - find_by(identifier: extract_identifier_from(host)) + find_by!(identifier: extract_identifier_from(host)) end private