Module: Controller::Actions::Create

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @record = _RC.new(permitted_params)

  authorize @record

  if @record.save
    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