Module: RESTFramework::CreateModelMixin
- Included in:
- ModelControllerMixin
- Defined in:
- lib/rest_framework/controller_mixins/models.rb
Overview
Mixin for creating records.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
262 263 264 |
# File 'lib/rest_framework/controller_mixins/models.rb', line 262 def create api_response(self.create!) end |
#create! ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/rest_framework/controller_mixins/models.rb', line 266 def create! if self.get_recordset.respond_to?(:create!) && self.create_from_recordset # Create with any properties inherited from the recordset. We exclude any `select` clauses in # case model callbacks need to call `count` on this collection, which typically raises a SQL # `SyntaxError`. @record ||= self.get_recordset.except(:select).create!(self.get_create_params) else # Otherwise, perform a "bare" create. @record ||= self.get_model.create!(self.get_create_params) end return self.serialize(@record) end |