Module: Controller::Actions::Destroy

Defined in:
lib/resourcify/controller/actions/destroy.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/resourcify/controller/actions/destroy.rb', line 3

def destroy
  authorize @record

  if @record.destroy
    render json: @record
  else
    @error[:type]     = 'Validation'
    @error[:message]  = 'Sorry, there were validation errors.'
    @error[:errors]   = @record.errors.messages
    @error[:messages] = @record.errors.full_messages

    render json: @error
  end
end