rails/rails — pull request #8638 by bogdan (2012-12-28 12:28:25+00:00)
Title: Improve a way to handle errors for collection nested attributes

Example:

``` ruby
Employment.validates :company, :presence => true
Developer.has_many :employments
Developer.accepts_nested_attributes_for :employments
d = Developer.new
2.times { d.employments.build }
d.valid?
d.errors.messages
```

Old result:

``` ruby
{
:"employments.company"=>["can't be blank"],
:email=>["can't be blank"],
:password=>["can't be blank"]
}

```

See that it is impossible to detect which `Employment` object is error related to.
In order to fix that propose to use an index(as Employment could be new - we can not use an id).
Only applied to collection associations.

New result

``` ruby
{
:"employments[0].company"=>["can't be blank"],
:"employments[1].company"=>["can't be blank"],
:email=>["can't be blank"],
:password=>["can't be blank"]
}

```