Module: Controller::Actions::Update

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

Instance Method Summary collapse

Instance Method Details

#updateObject



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

def update
  authorize @record

  if @record.update(permitted_params)
    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