diff --git a/config/application.rb b/config/application.rb index e6a5d0d..6bd8cc0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,7 +31,7 @@ class Application < Rails::Application config.autoload_lib(ignore: %w(assets tasks)) config.autoload_paths << Rails.root.join('lib') config.autoload_paths += %W(#{config.root}/lib) - Dir[Rails.root.join('app', 'middleware', '*.{rb}')].each { |file| require file } + config.middleware.use Middleware::ErrorHandler # Configuration for the application, engines, and railties goes here. diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dac88b7..815115d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= "test" -Dir[Rails.root.join("app/middleware/*.{rb}")].each { |file| require file } + require_relative "../config/environment" # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production?