Sha256: 818e526b0076791b3726f4bca118f16bcf07164788ba7dc879f9374497cc2174

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 Bytes

Contents

module MockleyCrew
  class Database::DataController < ApplicationController
    rescue_from MockleyCrew::Errors::InvalidDataError do |exception|
      render json: { success: false, message: "Invalid body structure" }, status: 400
    end

    rescue_from MockleyCrew::Errors::InvalidFactoryError do |exception|
      render json: { success: false, message: "Invalid Factory", detailed_error: exception }, status: 400
    end

    def create
      data = MockleyCrew::Data.new(data_params.to_h["_json"])
      if data.save
        render json: { success: true }, status: 201
      else
        render json: { success: false, request: data.as_json }, status: 422
      end
    end

    private

      def data_params
        params.permit!
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mockley_crew-1.1.1 app/controllers/mockley_crew/database/data_controller.rb
mockley_crew-1.1.0 app/controllers/mockley_crew/database/data_controller.rb
mockley_crew-1.0.0 app/controllers/mockley_crew/database/data_controller.rb