Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure #remove_#{column} and #remove_#{column} return false after com…

…mitting with ActiveRecord, closes #1318
  • Loading branch information...
commit 88352b4de06d68c4994e7ad22b50a6863380931f 1 parent 28a4363
@bensie bensie authored
View
4 lib/carrierwave/mount.rb
@@ -246,6 +246,10 @@ def remove_previously_stored_#{column}
end
end
+ def mark_remove_#{column}_false
+ _mounter(:#{column}).remove = false
+ end
+
RUBY
end
View
1  lib/carrierwave/orm/activerecord.rb
@@ -28,6 +28,7 @@ def mount_uploader(column, uploader=nil, options={}, &block)
after_save :"store_#{column}!"
before_save :"write_#{column}_identifier"
after_commit :"remove_#{column}!", :on => :destroy
+ after_commit :"mark_remove_#{column}_false", :on => :update
before_update :"store_previous_model_for_#{column}"
after_save :"remove_previously_stored_#{column}"
View
6 spec/orm/activerecord_spec.rb
@@ -376,6 +376,12 @@ def monkey
it "should clear the serialization column" do
expect(@event.attributes['image']).to be_blank
end
+
+ it "should return to false after being saved" do
+ @event.save!
+ @event.remove_image.should == false
+ @event.remove_image?.should == false
+ end
end
describe "#remote_image_url=" do
Please sign in to comment.
Something went wrong with that request. Please try again.