grape-active_model_serializers
grape-active_model_serializers copied to clipboard
Documentation on the ErrorSerializer
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!
Maybe turn it into a spec and we can take a look?
Looks like the PRs for error_formatter
being added didn't include a version bump and republish to ruby gems... The latest version published is 1.5.1.
https://github.com/ruby-grape/grape-active_model_serializers/pull/80
Are you saying HEAD has the code that works? If so you can close this.
I opened https://github.com/ruby-grape/grape-active_model_serializers/issues/84 to do a release, hopefully soon.