11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/motor/active_storage_attachments_controller.rb', line 11
def create
@attachment.assign_attributes(blob: ActiveStorage::Blob.create_and_upload!(file_params), record: record)
@attachment.assign_attributes(record_type: '', record_id: 0) unless record
if @attachment.save(validate: false)
render json: { data: Motor::ApiQuery::BuildJson.call(@attachment, params, current_ability) }
else
render json: { errors: @attachment.errors }, status: :unprocessable_entity
end
end
|