Sha256: 4ebb086e13cf65bb3aeb88ddde602ab00c9fb071872560f2a6f87db0b738d079

Contents?: true

Size: 1.61 KB

Versions: 7

Compression:

Stored size: 1.61 KB

Contents

require_dependency "integration_pal/application_controller"

module IntegrationPal
  class WorkersController < ApplicationController
    before_action :set_worker, only: [:show, :edit, :update, :destroy]

    # GET /workers
    def index
      @workers = Worker.all
    end

    # GET /workers/1
    def show
    end

    # GET /workers/new
    def new
      @worker = Worker.new
    end

    # GET /workers/1/edit
    def edit
    end

    # POST /workers
    def create
      @worker = Worker.new(worker_params)
      @worker.settings = params[:worker][:settings] || {}

      if @worker.save
        redirect_to @worker, notice: 'Worker was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /workers/1
    def update
      @worker.settings = params[:worker][:settings] || {}
      if @worker.update(worker_params)
        redirect_to @worker, notice: 'Worker was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /workers/1
    def destroy
      @worker.destroy
      redirect_to workers_url, notice: 'Worker was successfully destroyed.'
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_worker
        @worker = Worker.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def worker_params
        params[:worker] ||= {}
        params[:worker][:settings] ||= {}
        params[:worker][:settings].permit!
        params.require(:worker).permit(:name, :access_id, :secret_key, :job_type, :settings, settings: params[:worker][:settings].keys)
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
integration_pal-0.2.3 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.2.2 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.2.1 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.2.0 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.1.6 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.1.5 app/controllers/integration_pal/workers_controller.rb
integration_pal-0.1.4 app/controllers/integration_pal/workers_controller.rb