/nested_attributes_validation_bug

Example of bug with nested attributes validation

Primary LanguageRuby

When using the update_attributes for nested attributes, the inner model gets out of sync. The bug was identifed on Rails 3.1.1.

Console code: 
======
```ruby
e = Employee.create(name: 'rafael', active: false)
b = Badge.create(number: 1, employee: e)
a = Address.create(street: "123 Market St", city: "San Diego", employee: e)

e = Employee.first
e.is_active?
e.badge.employee.is_active?
e.addresses.first.employee.is_active?
e.active = true
e.update_attributes({name: 'Rafael', active: true, :badge_attributes=>{id: 1, number: 1}, :addresses_attributes => {"0" => {id: 1, street: "321 First St", city: "Santa Monica"}}})
e.is_active?
e.badge.employee.is_active?
e.addresses.first.employee.is_active?
```