Skip to content

Commit

Permalink
Fix: Extensions aren't loaded in development/test
Browse files Browse the repository at this point in the history
PR #19 previously loaded the associated object class when the has_object
was defined, so that extensions would get run. It seems like that code
got lost in a rebase. So now, extensions only run on boot if eager
loading is enabled (which it is in production). Otherwise they aren't
loaded until the first time the associated object gets used.
  • Loading branch information
natematykiewicz committed Jan 22, 2024
1 parent f68062f commit 0f6935b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_record/associated_object/object_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def extend_source_from(chunks, &block)
module ClassMethods
def has_object(*names, **callbacks)
extend_source_from(names) do |name|
"def #{name}; (@associated_objects ||= {})[:#{name}] ||= #{name.to_s.classify}.new(self); end"
"def #{name}; (@associated_objects ||= {})[:#{name}] ||= #{const_get(name.to_s.classify)}.new(self); end"
end

extend_source_from(names) do |name|
Expand Down

0 comments on commit 0f6935b

Please sign in to comment.