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

Changeset 3753

Show
Ignore:
Timestamp:
03/03/06 06:25:39 (4 years ago)
Author:
david
Message:

Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen (closes #4058) [anna@wota.jp]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3734 r3753  
    11*SVN* 
     2 
     3* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp] 
    24 
    35* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant, but has the following caveats: 
  • trunk/activerecord/lib/active_record/associations/has_one_association.rb

    r3586 r3753  
    3535          else 
    3636            @target[@reflection.primary_key_name] = nil 
    37             @target.save unless @owner.new_record? 
     37            @target.save unless @owner.new_record? || @target.new_record? 
    3838          end 
    3939        end 
  • trunk/activerecord/test/associations_test.rb

    r3452 r3753  
    157157    assert !account.save 
    158158    assert_equal "can't be empty", account.errors.on("credit_limit") 
     159  end 
     160 
     161  def test_build_association_twice_without_saving_affects_nothing 
     162    count_of_account = Account.count 
     163    firm = Firm.find(:first) 
     164    account1 = firm.build_account("credit_limit" => 1000) 
     165    account2 = firm.build_account("credit_limit" => 2000) 
     166 
     167    assert_equal count_of_account, Account.count 
    159168  end 
    160169