Method: Scimitar::ActiveRecordBackedResourcesController#create
- Defined in:
- app/controllers/scimitar/active_record_backed_resources_controller.rb
#create(&block) ⇒ Object
POST (create)
Calls #save! on the new record if no block is given, else invokes the block, passing it the new ActiveRecord model instance to be saved. It is up to the block to make any further changes and persist the record.
Blocks are invoked from within a wrapping database transaction. ActiveRecord::RecordInvalid exceptions are handled for you, rendering an appropriate SCIM error.
69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/scimitar/active_record_backed_resources_controller.rb', line 69 def create(&block) super do |scim_resource| self.storage_class().transaction do record = self.storage_class().new record.from_scim!(scim_hash: scim_resource.as_json()) self.save!(record, &block) record_to_scim(record) end end end |