Commit b491f2a3 by Mike Burns

Move the after_destroy callback out

parent 2ba27691
...@@ -175,8 +175,6 @@ module Paperclip ...@@ -175,8 +175,6 @@ module Paperclip
def has_attached_file(name, options = {}) def has_attached_file(name, options = {})
HasAttachedFile.define_on(self, name, options) HasAttachedFile.define_on(self, name, options)
after_destroy { send(name).send(:flush_deletes) }
define_paperclip_callbacks :post_process, :"#{name}_post_process" define_paperclip_callbacks :post_process, :"#{name}_post_process"
end end
end end
......
...@@ -73,6 +73,7 @@ module Paperclip ...@@ -73,6 +73,7 @@ module Paperclip
name = @name name = @name
@klass.send(:after_save) { send(name).send(:save) } @klass.send(:after_save) { send(name).send(:save) }
@klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) } @klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) }
@klass.send(:after_destroy) { send(name).send(:flush_deletes) }
end end
end end
end end
...@@ -30,6 +30,10 @@ class HasAttachedFileTest < Test::Unit::TestCase ...@@ -30,6 +30,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should 'define a before_destroy callback' do should 'define a before_destroy callback' do
assert_adding_attachment('avatar').defines_callback('before_destroy') assert_adding_attachment('avatar').defines_callback('before_destroy')
end end
should 'define an after_destroy callback' do
assert_adding_attachment('avatar').defines_callback('after_destroy')
end
end end
private private
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment