Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2009: has_many_belongs_to_fix.diff

File has_many_belongs_to_fix.diff, 0.7 kB (added by robbyrussell, 3 years ago)

patch for associations.rb

  • associations.rb

    old new  
    299299          module_eval "before_destroy '#{association_name}.each { |o| o.destroy }'" 
    300300        elsif options[:exclusively_dependent] 
    301301          module_eval "before_destroy { |record| #{association_class_name}.delete_all(%(#{association_class_primary_key_name} = \#{record.quoted_id})) }" 
     302        else 
     303          module_eval "before_destroy '#{association_class_name}.update_all(%(#{association_class_primary_key_name} = NULL))'"  
    302304        end 
    303305 
    304306        add_multiple_associated_save_callbacks(association_name)