From 0befcf00659cf66b40edb654cd2553a04da60192 Mon Sep 17 00:00:00 2001 From: Wendel Fabian Chinsamy Date: Mon, 20 May 2024 16:49:12 +0200 Subject: [PATCH 1/2] fix zeitwerk load errors --- README.md | 6 ++++++ app/controllers/application_controller.rb | 1 + config/application.rb | 14 ++++++++------ config/initializers/middlewares.rb | 2 ++ lib/middleware/compressed_requests.rb | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 520ed0d..40f7fb3 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ We use Rspec for unit and acceptance testing: bundle exec rspec ``` +To run the Rails console: + +``` +DISABLE_SPRING=true bundle exec rails console +``` + ## Technical Description ### Resource components diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3477ee0..63c66d6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,6 +79,7 @@ def transform_params elsif status == 409 message = "The resource already exists." else + Raven.capture_exception(exception) message = exception.message end diff --git a/config/application.rb b/config/application.rb index 27358d8..db4435a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -55,12 +55,11 @@ module Sashimi class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.1 - config.autoload_paths << Rails.root.join('lib') + config.autoload_once_paths << Rails.root.join('lib') config.autoload_paths << Rails.root.join("app", "models", "concerns") - config.autoload_paths += %W(#{config.root}/lib #{config.root}/lib/middleware) - # Allow middleware to be loaded. (compressed_requests) - config.autoload_lib(ignore: nil) + config.eager_load_paths << Rails.root.join("lib") + config.eager_load_paths << Rails.root.join("app", "models", "concerns") # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -76,8 +75,8 @@ class Application < Rails::Application config.lograge.enabled = true config.lograge.formatter = Lograge::Formatters::Logstash.new config.lograge.logger = LogStashLogger.new(type: :stdout) - config.logger = config.lograge.logger ## LogStashLogger needs to be pass to rails logger, see roidrage/lograge#26 - config.log_level = ENV["LOG_LEVEL"].to_sym ## Log level in a config level configuration + config.logger = config.lograge.logger + config.log_level = ENV["LOG_LEVEL"].to_sym config.lograge.ignore_actions = ["HeartbeatController#index", "IndexController#index"] config.lograge.ignore_custom = lambda do |event| @@ -93,6 +92,9 @@ class Application < Rails::Application } end + config.action_dispatch.show_exceptions = :all + config.action_dispatch.debug_exception_log_level = :error + # configure caching config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"], { namespace: ENV["APPLICATION"] } diff --git a/config/initializers/middlewares.rb b/config/initializers/middlewares.rb index 52cb939..0c801ef 100644 --- a/config/initializers/middlewares.rb +++ b/config/initializers/middlewares.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "./lib/middleware/compressed_requests" Rails.application.configure do diff --git a/lib/middleware/compressed_requests.rb b/lib/middleware/compressed_requests.rb index 04882bd..13d1493 100644 --- a/lib/middleware/compressed_requests.rb +++ b/lib/middleware/compressed_requests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Middleware class CompressedRequests def initialize(app) From 257dbc93dcac236c1b7b15eef1f20f21cbb6f327 Mon Sep 17 00:00:00 2001 From: Wendel Fabian Chinsamy Date: Mon, 20 May 2024 16:59:43 +0200 Subject: [PATCH 2/2] configure application error logging --- config/application.rb | 1 - config/environments/development.rb | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index db4435a..8889e4c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -92,7 +92,6 @@ class Application < Rails::Application } end - config.action_dispatch.show_exceptions = :all config.action_dispatch.debug_exception_log_level = :error # configure caching diff --git a/config/environments/development.rb b/config/environments/development.rb index 23ae1ea..719714b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -66,6 +66,8 @@ url: "/report_files/:filename", use_timestamp: false, } + + config.action_dispatch.show_exceptions = false end #BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP']