From 49fdf5bf068fa6215c8c5693b4248729625457ef Mon Sep 17 00:00:00 2001 From: Daniel Kastl Date: Tue, 19 Nov 2024 11:46:49 +0900 Subject: [PATCH] Refactor initialization logic after dropping support for Redmine 4 --- init.rb | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/init.rb b/init.rb index 5a2ad55..955d765 100644 --- a/init.rb +++ b/init.rb @@ -56,37 +56,12 @@ config.register RGeo::Cartesian.preferred_factory(has_z_coordinate: true, srid: 4326), geo_type: 'geometry', sql_type: "geometry", srid: 4326 end -if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled? - Dir.glob("#{Rails.root}/plugins/redmine_gtt/app/overrides/**/*.rb").each do |path| - Rails.autoloaders.main.ignore(path) - require path - end - RedmineGtt.setup_normal_patches - Rails.application.config.after_initialize do - RedmineGtt.setup_controller_patches - end -else - require 'redmine_gtt' - # Configure View Overrides - Rails.application.paths["app/overrides"] ||= [] - Rails.application.paths["app/overrides"] << File.expand_path("../app/overrides", __FILE__) - - ActiveSupport::Reloader.to_prepare do - RedmineGtt.setup_normal_patches - - # ActiveRecord::Base.include_root_in_json = true - # module RGeo - # module Feature - # module Point - # def as_json(params) - # ::RGeo::GeoJSON.encode(self) - # end - # end - # end - # end - end +Dir.glob("#{Rails.root}/plugins/redmine_gtt/app/overrides/**/*.rb").each do |path| + Rails.autoloaders.main.ignore(path) + require path +end - Rails.configuration.to_prepare do - RedmineGtt.setup_controller_patches - end +RedmineGtt.setup_normal_patches +Rails.application.config.after_initialize do + RedmineGtt.setup_controller_patches end