Skip to content

Commit

Permalink
fix to dup mounters cache on mount
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan committed Aug 27, 2023
1 parent c35f486 commit e53c9c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/carrierwave/mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ def write_uploader(column, identifier); end

private

def initialize_dup(other)
@_mounters = @_mounters.dup
super
end

def _mounter(column)
# We cannot memoize in frozen objects :(
return Mounter.build(self, column) if frozen?
Expand Down
1 change: 0 additions & 1 deletion lib/carrierwave/orm/activerecord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def reload(*)
# Reset cached mounter on record dup
def initialize_dup(other)
old_uploaders = _mounter(:"#{column}").uploaders
@_mounters = @_mounters.dup
@_mounters[:"#{column}"] = nil
super
# The attribute needs to be cleared to prevent it from picked up as identifier
Expand Down

0 comments on commit e53c9c3

Please sign in to comment.