Skip to content

Commit

Permalink
Check filters after app is initialized
Browse files Browse the repository at this point in the history
Avoids accessing models that are not loaded yet: `NameError: uninitialized constant Event`
  • Loading branch information
fbacall committed Aug 24, 2023
1 parent 2f8c509 commit c088fcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# The core application helper
module ApplicationHelper
IGNORED_FILTERS = %w[user].freeze

# def bootstrap_class_for flash_type
# { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
# end
Expand Down
12 changes: 12 additions & 0 deletions config/initializers/check_hidden_filters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen-string-literal: true

Rails.configuration.after_initialize do
# check the filter lists for correctness
if TeSS::Config.solr_enabled && TeSS::Config.solr_facets.present?
TeSS::Config.solr_facets.each_pair do |name, keys|
unknown_facets = Set.new(keys) - name.classify.constantize.facet_keys

raise "unknown facets defined for #{name}: #{unknown_facets}" if unknown_facets.any?
end
end
end
17 changes: 0 additions & 17 deletions config/initializers/zz_hidden_filters.rb

This file was deleted.

0 comments on commit c088fcf

Please sign in to comment.