Skip to content

Add a CRUD extension #8

Closed
Closed

Description

@dblock

See https://github.com/dblock/grape-with-roar/blob/765b6fc0c117e70546161ced37da86cc0e18a8d4/api/extensions/crud_extension.rb, a simple CRUD extension that lets you write API crud in a much more elegant way.

create

spline = create Acme::Models::Spline, with: Acme::Api::Presenters::SplinePresenter, from: params[:spline]
present spline, with: Acme::Api::Presenters::SplinePresenter

update

spline = Acme::Models::Spline.find(params[:uuid])
update spline, with: Acme::Api::Presenters::SplinePresenter, from: params[:spline]

delete

spline = Acme::Models::Spline.find(params[:uuid])
delete spline, with: Acme::Api::Presenters::SplinePresenter

Activity

  1. dblock commented on Oct 27, 2026

    @dblock
    MemberAuthor

    PR #49 adds a complete application-local CRUD recipe rather than introducing a generic persistence API or globally patching Grape endpoints. It uses separate input/output decorators, Grape validation, filtered writable fields, partial updates, and explicit save!/destroy! calls. Authorization and expected-error HTTP mappings remain application responsibilities.

    The exact README example runs through create/update/delete request specs with persistence doubles. These verify readonly fields are not assigned, omitted update fields are preserved, invalid input does not save, and persistence exceptions propagate rather than returning success.

    Posted by Copilot, an AI, on behalf of @dblock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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