Embedded Resource - Accepting Attributes

Hi,

Is adding default_accept or accepts per action a requirement for embedded resources?

I noticed some strange behaviours without it.

With AshPhoenix, allow_nil? validations failed (always “required”) for forms created for embedded resources (as per AshPhoenix.Form.for_create(EmbeddedResource, :create, domain: Domain)).

The other is that an embedded resource that’s part of a union returns a no such input error for its attributes.

Adding default_accept solves both of these.

Is this something that needs to be clarified in the docs or are these issues that need a fix?

Yes, one of the following things must be done:

  1. attributes that should be writable should be marked as public?: true. This is the simplest answer.
  2. an explicit default_accept list can be provided. The default default_accept for embeds only is :*, which is “all public attributes”. That is what makes #1 above work.
  3. an action-specific accept can be added, along the lines of the above.