Module: RESTFramework::CreateModelMixin

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

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)
end