Skip to content

Documentation on the ErrorSerializer #83

@dja

Description

@dja

I've tried getting it to serialize ActiveModel errors, but to no avail.

Here's what I've got going on..

I've tried both of these for good measure.

# /api/v1/defaults.rb
error_formatter :json, Grape::Formatter::ActiveModelSerializers
error_formatter :jsonapi, Grape::Formatter::ActiveModelSerializers
# api/v1/users.rb, includes defaults

params do
  requires :id, types: String, desc: 'User ID'
end
route_param :id do
  before do
    @user = User.where(id: params[:id]).first!
  end

  desc 'Update a user'
  params do
    optional :first_name, type: String, desc: 'First Name'
    optional :last_name, type: String, desc: 'Last Name'
    optional :email, type: String, desc: 'Email Address'
  end
  patch do
      @user.update(params)
  end
end

Any suggestions greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions