Module: RESTFramework::CreateModelMixin

Included in:
ModelControllerMixin
Defined in:
lib/rest_framework/controllers/models.rb

Instance Method Summary collapse

Instance Method Details

#createObject



167
168
169
170
171
172
173
174
# File 'lib/rest_framework/controllers/models.rb', line 167

def create
  begin
    @record = self.get_model.create!(self.get_create_params)
  rescue ActiveRecord::RecordInvalid => e
    api_response(e.record.messages, status: 400)
  end
  api_response(@record, **self.get_model_serializer_config)
end