Skip to content

Nested errors #10

Open
Open
@kirs

Description

@kirs

My form:

class RegistrationForm < ActiveForm::Base
  self.main_model = :user

  attributes :email, :password

  association :company do
    attributes :name, :email, :phone
  end
end

When I submit it with such params:

{
  email: "", password: "", company_attributes: { name: "foo", email: ""}
}

Emails errors are:

@form.errors[:email]
=> ["Can't be blank", "Can't be blank"]

I find it weird that email errors are duplicated even if the fields have similar name.
Should we return a hash of errors to avoid it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions