Skip to content

Commit

Permalink
Support Rails 7.2 normalized reflections API
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorton committed May 31, 2024
1 parent 6d939b2 commit 7a6c659
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ def record_having_one_attached(
end

if remove_attachments
reflections.delete("#{attached_name}_attachment")
if respond_to?(:normalized_reflections)
clear_reflections_cache
_reflections.delete("#{attached_name}_attachment".to_sym)
normalized_reflections
else
reflections.delete("#{attached_name}_attachment")
end
end

if invalidate_blobs
Expand Down Expand Up @@ -223,7 +229,13 @@ def record_having_many_attached(
end

if remove_attachments
reflections.delete("#{attached_name}_attachments")
if respond_to?(:normalized_reflections)
clear_reflections_cache
_reflections.delete("#{attached_name}_attachments".to_sym)
normalized_reflections
else
reflections.delete("#{attached_name}_attachments")
end
end

if invalidate_blobs
Expand Down

0 comments on commit 7a6c659

Please sign in to comment.