From e20fa1a4642767cd5e38dbd92876536b08f6026d Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Thu, 19 Sep 2024 14:14:31 +0200 Subject: [PATCH] Prefer require_relative for internal requires `require_relative` is preferred over `require` for files within the same project because it uses paths relative to the current file, making code more portable and less dependent on the load path. This change updates internal requires to use `require_relative` for consistency, performance, and improved portability. Ref: - activeadmin/arbre#622 --- lib/inherited_resources.rb | 7 ++++--- lib/inherited_resources/base_helpers.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/inherited_resources.rb b/lib/inherited_resources.rb index ae8c1455..bc0d68d4 100644 --- a/lib/inherited_resources.rb +++ b/lib/inherited_resources.rb @@ -3,9 +3,10 @@ # This is here because responders don't require it. require 'rails/engine' require 'responders' -require 'inherited_resources/engine' -require 'inherited_resources/blank_slate' -require 'inherited_resources/responder' + +require_relative 'inherited_resources/engine' +require_relative 'inherited_resources/blank_slate' +require_relative 'inherited_resources/responder' module InheritedResources ACTIONS = [ :index, :show, :new, :edit, :create, :update, :destroy ] unless self.const_defined?(:ACTIONS) diff --git a/lib/inherited_resources/base_helpers.rb b/lib/inherited_resources/base_helpers.rb index 10fafdae..a352ea39 100644 --- a/lib/inherited_resources/base_helpers.rb +++ b/lib/inherited_resources/base_helpers.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Whenever base is required load the dumb responder since it's used inside actions. -require 'inherited_resources/blank_slate' +require_relative 'blank_slate' module InheritedResources # Base helpers for InheritedResource work. Some methods here can be overwritten