Skip to content

has_many and nested attributes #25198

@deanpcmad

Description

@deanpcmad

Steps to reproduce

  • A Customer model has accepts_nested_attributes_for :phones and has_many :phones.
  • The Phone model has belongs_to :customer

When creating a customer with phone attributes, the validations prevent the number (and customer) from being created.

Please see both of these repos:

Rails 4.2.6 works without an issue.

If I disable validations in the controller when saving the customer (by changing @customer.save to @customer.save(validate: false)), both models save and work as expected

Expected behavior

The customer should be saved. The phone should also be saved linked to the customer

Actual behavior

The customer and phone fails to save and throws a validation error
screen shot 2016-05-30 at 17 49 35

System configuration

Rails version: 5.0.0.rc1

Ruby version: 2.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close