require_dependency "fieri/application_controller"

module Fieri
  class JobsController < ApplicationController
    def create
      CookbookWorker.perform_async(job_params)
      render text: "ok"
    rescue ActionController::ParameterMissing => e
      render status: 400, text: "Error: #{e.message}"
    end

    private

    def job_params
      [:cookbook_name, :cookbook_version, :cookbook_artifact_url].each do |param|
        params.require(param)
      end
      params
    end
  end
end

require_dependency "fieri/application_controller"

module Fieri
  class JobsController < ApplicationController
    def create
      CookbookWorker.perform_async(job_params)
      render json: { status: 'ok' }.to_json
    rescue ActionController::ParameterMissing => e
      render status: 400, json: { status: 'error',
                                  message: e.message }
    end

    private

    def job_params
      [:cookbook_name, :cookbook_version, :cookbook_artifact_url].each do |param|
        params.require(param)
      end
      params
    end
  end
end

Change to JSON responses from /jobs
Change to JSON responses from /jobs
