nolith / habtm-with-deferred-save

Rails plugin. Defers saving the records you add to habtm association until you call model.save, allowing validation in the style of normal attributes.

Changed (Δ140 bytes):

Up to file-list has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb:

@@ -21,6 +21,9 @@ module ActiveRecord
21
21
        has_and_belongs_to_many *args
22
22
        collection_name = args[0].to_s
23
23
        collection_singular_ids = collection_name.singularize + "_ids"
24
        
25
        # this will delete all the assocation into the join table after obj.destroy
26
        after_destroy { |record| record.save }
24
27
25
28
        attr_accessor :"unsaved_#{collection_name}"
26
29
        attr_accessor :"use_original_collection_reader_behavior_for_#{collection_name}"