# HG changeset patch # User Alessio Caiazza # Date 1266064626 -3600 # Node ID c7287bf557dd8af22fd417f13d894fcb511c8f0c # Parent d8a7e572f5cc045a1c8005559307438e438571c1 FIX: delete all the assocation into the join table after obj.destroy diff -r d8a7e572f5cc045a1c8005559307438e438571c1 -r c7287bf557dd8af22fd417f13d894fcb511c8f0c has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb --- a/has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb Sat Feb 13 13:34:41 2010 +0100 +++ b/has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb Sat Feb 13 13:37:06 2010 +0100 @@ -21,6 +21,9 @@ has_and_belongs_to_many *args collection_name = args[0].to_s collection_singular_ids = collection_name.singularize + "_ids" + + # this will delete all the assocation into the join table after obj.destroy + after_destroy { |record| record.save } attr_accessor :"unsaved_#{collection_name}" attr_accessor :"use_original_collection_reader_behavior_for_#{collection_name}"