Commit 2ba27691 by Mike Burns

Move the before_destroy callback out

parent 56a2cd69
...@@ -175,7 +175,6 @@ module Paperclip ...@@ -175,7 +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)
before_destroy { send(name).send(:queue_all_for_delete) }
after_destroy { send(name).send(:flush_deletes) } after_destroy { send(name).send(:flush_deletes) }
define_paperclip_callbacks :post_process, :"#{name}_post_process" define_paperclip_callbacks :post_process, :"#{name}_post_process"
......
...@@ -72,6 +72,7 @@ module Paperclip ...@@ -72,6 +72,7 @@ module Paperclip
def add_active_record_callbacks def add_active_record_callbacks
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) }
end end
end end
end end
...@@ -26,6 +26,10 @@ class HasAttachedFileTest < Test::Unit::TestCase ...@@ -26,6 +26,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should 'define an after_save callback' do should 'define an after_save callback' do
assert_adding_attachment('avatar').defines_callback('after_save') assert_adding_attachment('avatar').defines_callback('after_save')
end end
should 'define a before_destroy callback' do
assert_adding_attachment('avatar').defines_callback('before_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