diff --git a/lib/carrierwave/orm/activerecord.rb b/lib/carrierwave/orm/activerecord.rb index f7f73e108..a351b1800 100644 --- a/lib/carrierwave/orm/activerecord.rb +++ b/lib/carrierwave/orm/activerecord.rb @@ -44,9 +44,9 @@ def reload(*) def initialize_dup(other) old_uploaders = _mounter(:"#{column}").uploaders @_mounters[:"#{column}"] = nil + super # The attribute needs to be cleared to prevent it from picked up as identifier write_attribute(:"#{column}", nil) - super _mounter(:"#{column}").cache(old_uploaders) end diff --git a/spec/orm/activerecord_spec.rb b/spec/orm/activerecord_spec.rb index 30c4761d6..747766419 100644 --- a/spec/orm/activerecord_spec.rb +++ b/spec/orm/activerecord_spec.rb @@ -1960,6 +1960,12 @@ def reload(*) expect(new_event.image.url).to eq '/uploads/test.jpeg' end + it "does not modify the original object" do + @event.image = stub_file('test.jpeg') + @event.save + expect { @event.dup }.not_to change { @event[:image] } + end + context "with more than one mount" do before do @uploader1 = Class.new(CarrierWave::Uploader::Base)