Skip to content

Disassociating a required belongs_to should raise error #95

Open
@richmolj

Description

@richmolj

If Post has many Comments, and you try to sidepost disassociate a comment, it will silently fail. Instead, we should raise an expressive error message.

The issue is that Rails 5 defaults belongs_to to be required and will fail validation if the foreign key is nil. So we attempt to disassociate these objects, but no DB update is made. This error should be a 422 validation error but since these objects are already disassociate in memory we never know to do so.

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