There seems to be some confusion here about what :update_only means in accepts_nested_attributes_for in Rails Admin. It is currently use to decide to show the subform for a child record when creating a new record. I don't think this is correct.
For a one-to-one association, this option allows you to specify how nested attributes are going to be used when an associated record already exists. In general, an existing record may either be updated with the new set of attribute values or be replaced by a wholly new record containing those values. By default the :update_only option is false and the nested attributes are used to update the existing record only if they include the record’s :id value. Otherwise a new record will be instantiated and used to replace the existing one. However if the :update_only option is true, the nested attributes are used to update the record’s attributes always, regardless of whether the :id is present. The option is ignored for collection associations.
This PR no longer attempts to use update_only, and only looks at field.inline_add.
Also as a bonus removing an unless with || makes my Grug brain happy.
Closes #2626
There seems to be some confusion here about what
:update_only
means inaccepts_nested_attributes_for
in Rails Admin. It is currently use to decide to show the subform for a child record when creating a new record. I don't think this is correct.https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
This PR no longer attempts to use
update_only
, and only looks atfield.inline_add
.Also as a bonus removing an
unless
with||
makes my Grug brain happy.