HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
Make nested_attributes plugin add newly created objects to cached ass…
…ociation array immediately The reasoning behind this is that if this isn't done, the current object has no way to access the nested attribute records until after the save. The general use case for nested_attributes is a web form that handles dependent records. Without any access to the nested records, it is very difficult to handle validation failures and display nice error messages to the user if dependent records are not valid. This approach adds the newly created records to the cached array, so if validation fails, you can just iterate over the cached array, and it will have both previously existing and new records in it. This change does not affect many_to_one associations, since they don't have a cached association array, and setting the object in the cached association would probably cause issues. This also doesn't affect updating existing records, since those are already in the array.
- Loading branch information...
Showing with 9 additions and 0 deletions.