Improved order of callback for destroy (delete references first).

This commit is contained in:
Martin Edenhofer 2014-08-26 16:24:44 +02:00
parent 62b07e2f35
commit 5f401a7b04
2 changed files with 5 additions and 4 deletions

View file

@ -21,7 +21,7 @@ class ApplicationModel < ActiveRecord::Base
after_create :activity_stream_create
after_update :activity_stream_update
after_destroy :activity_stream_destroy
before_destroy :activity_stream_destroy
after_create :history_create
after_update :history_update
@ -31,7 +31,7 @@ class ApplicationModel < ActiveRecord::Base
after_update :search_index_update
after_destroy :search_index_destroy
after_destroy :recent_view_destroy
before_destroy :recent_view_destroy
# create instance accessor
class << self

View file

@ -22,6 +22,7 @@ class RecentView < ApplicationModel
end
def self.log_destroy( requested_object, requested_object_id )
return if requested_object == 'RecentView'
RecentView.where( :recent_view_object_id => ObjectLookup.by_name( requested_object ) ).
where( :o_id => requested_object_id ).
destroy_all