Skip to content

Commit

Permalink
Destroy callback hooks into before_destroy instead of after_commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Pheasey committed Jun 6, 2016
1 parent 21ff62f commit 975886e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/active_touch/define_touch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def initialize(klass, association, options)

def define
define_update_touch_method
add_active_record_callback(@update_touch_method)
add_active_record_callback(:after_commit, @update_touch_method)

define_destroy_touch_method
add_active_record_callback(@destroy_touch_method)
add_active_record_callback(:after_destroy, @destroy_touch_method)

add_to_network
end
Expand Down Expand Up @@ -60,8 +60,8 @@ def define_destroy_touch_method
end
end

def add_active_record_callback(method)
@klass.send(:after_commit) { send(method) }
def add_active_record_callback(event, method)
@klass.send(event) { send(method) }
end

def add_to_network
Expand Down
2 changes: 1 addition & 1 deletion lib/active_touch/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActiveTouch
VERSION = '4.0.0'
VERSION = '4.0.1'
end

0 comments on commit 975886e

Please sign in to comment.