Module: Grape::App::Helpers::RespondWith

Defined in:
lib/grape/app/helpers/respond_with.rb

Defined Under Namespace

Classes: Errors

Instance Method Summary collapse

Instance Method Details

#respond_with(record, opts = {}) ⇒ Object

Parameters:

  • record (ActiveRecord::Base)

    validated record



9
10
11
12
13
14
15
# File 'lib/grape/app/helpers/respond_with.rb', line 9

def respond_with(record, opts = {})
  unless record.errors.empty?
    opts[:with] = Errors
    status 400
  end
  present record, opts
end