Sha256: cd30318c7eeaa901ab5a62eaff0809badc1d6505efa9795b75fbe5d9f835aa77

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Logistics
  module Core
    class AddendumsController < ApplicationController

      # GET /addendums
      # GET /addendums.json
      def index
        @addendums = Addendum.where('service_increment_id' => params[:service_increment_id])
        @response = {:success => true, :message => '', :data => @addendums}
        render json: @response
      end

      # POST /addendums
      # POST /addendums.json
      def create
        @addendum = Addendum.new(addendum_params)

        if @addendum.valid?
          service_increment = ServiceIncrement.find(params[:service_increment_id])
          addendum = service_increment.addendums << @addendum
          @response = {:success => true, :message => 'Addition created successfully', :data => addendum}
          render json: @response
        else
          @response = {:success => false, :message => 'Error saving addition', :data => []}
          render json: @response
        end
      end

      def get_all
        @addendums = Addendum.all
        @response = {:success => true, :message =>'', :data =>@addendums}
        render json: @response
      end

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

        # Never trust parameters from the scary internet, only allow the white list through.
        def addendum_params
          params.require(:addendum).permit(:service_increment_id, :addition_id)
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/controllers/logistics/core/addendums_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/addendums_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/addendums_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/addendums_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/addendums_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/addendums_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/addendums_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/addendums_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/addendums_controller.rb