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

Ticket #5216: habtm_join_table_test.patch1.diff

File habtm_join_table_test.patch1.diff, 0.9 kB (added by anonymous, 3 years ago)

patch for test_join_notid. not copying value into join_table if column is record's primary key

  • lib/active_record/associations/has_and_belongs_to_many_association.rb

    old new  
    113113                  attributes[column.name] = @owner.quoted_id 
    114114                when @reflection.association_foreign_key 
    115115                  attributes[column.name] = record.quoted_id 
     116                when record.class.primary_key 
     117                  # if its record's primary key, its almost always wrong to use  
     118                  # its value for the join_table insertion.  
    116119                else 
    117120                  if record.attributes.has_key?(column.name) 
    118121                    value = @owner.send(:quote, record[column.name], column)