From afb99deca0f8b8a55c0a1a466a24c1ea071ecee1 Mon Sep 17 00:00:00 2001 From: iberianpig Date: Wed, 2 Aug 2023 18:28:54 +0900 Subject: [PATCH] require reflection_extensions when ActiveRecordExtensions is extended `extend ActiveHash::Associations::ActiveRecordExtensions` does not require 'reflection_extensions' so the following error occurs when `compute_class` is called in Rails 7. ``` ArgumentError: Rails couldn't find a valid model for Rank association. Please provide the :class_name option on the association declaration. If :class_name is already provided, make sure it's an ActiveRecord::Base subclass. ``` --- lib/associations/associations.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/associations/associations.rb b/lib/associations/associations.rb index e41a7cd0..99e2f046 100644 --- a/lib/associations/associations.rb +++ b/lib/associations/associations.rb @@ -3,6 +3,10 @@ module Associations module ActiveRecordExtensions + def self.extended(base) + require_relative 'reflection_extensions' + end + def belongs_to(name, scope = nil, **options) klass_name = options.key?(:class_name) ? options[:class_name] : name.to_s.camelize klass = @@ -92,7 +96,6 @@ def belongs_to_active_hash(association_id, options = {}) end def self.included(base) - require_relative "reflection_extensions" base.extend Methods end