lib/attachs/concern.rb in attachs-4.0.0.0 vs lib/attachs/concern.rb in attachs-4.0.0.1

- old
+ new

@@ -8,17 +8,25 @@ after_commit :destroy_attachments, on: :destroy after_rollback :unpersist_attachments end def reload(options=nil) - super.tap do - self.class.attachments.keys.each do |attribute| - instance_variable_set "@#{attribute}", nil - end - end + clear_attachments + super end private + + def initialize_dup(other) + clear_attachments + super + end + + def clear_attachments + self.class.attachments.keys.each do |attribute| + instance_variable_set "@#{attribute}", nil + end + end %i(save destroy persist unpersist).each do |method| define_method "#{method}_attachments" do self.class.attachments.keys.each do |attribute| send(attribute).send method