Skip to content

Commit

Permalink
require reflection_extensions when ActiveRecordExtensions is extended
Browse files Browse the repository at this point in the history
`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.
```
  • Loading branch information
iberianpig committed Aug 2, 2023
1 parent 4d08471 commit afb99de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/associations/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit afb99de

Please sign in to comment.