Sha256: ce40fdf2a4acdda49b995aaa62659b848e7592de520e457f231122fbb1244997

Contents?: true

Size: 672 Bytes

Versions: 2

Compression:

Stored size: 672 Bytes

Contents

require_dependency "integration_pal/application_controller"

module IntegrationPal
  class Api::V1::JobsController < ApiController
    # GET /jobs/1
    def show
      @job = Job.find(params[:id])
      render json: @job, status: :success
    end

    # POST /jobs
    def create
      @job = Job.new(job_params)
      if @job.save
        @job.worker.job_class.perform_later(@job.id)
        render json: @job, status: :success
      else
        render json: {errors: @job.errors}, status: :unprocessable_entity
      end
    end

  private

    def job_params
      params.require(:job).permit(:worker_id, job_params: params[:job][:job_params].keys)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
integration_pal-0.1.1 app/controllers/integration_pal/api/v1/jobs_controller.rb
integration_pal-0.1.0 app/controllers/integration_pal/api/v1/jobs_controller.rb