Skip to content

Commit

Permalink
Rewrite confusing code for getting association class
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Dec 15, 2024
1 parent 31953d2 commit 2fe2cd4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions activerecord/lib/active_record/reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,14 @@ def klass

def _klass(class_name) # :nodoc:
if active_record.name.demodulize == class_name
return compute_class("::#{class_name}") rescue NameError
begin
compute_class("::#{class_name}")
rescue NameError
compute_class(class_name)
end
else
compute_class(class_name)
end

compute_class(class_name)
end

def compute_class(name)
Expand Down

0 comments on commit 2fe2cd4

Please sign in to comment.