Sha256: e5ab3cd702c582aae18981cdf5ad9725f8022cad86c6b122dbb715c21de93bf3

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Mks
  module Edm
    class EquipmentComponentsController < ApplicationController
      before_action :set_equipment_component, only: %i[show update]

      def index
        @equipment_components = EquipmentComponent.where(equipment_item_id: params[:id])
        render json: @equipment_components
      end

      def show
        render json: @equipment_component
      end

      def create
        @equipment_component = EquipmentComponent.new(equipment_component_params)

        if @equipment_component.save
          render json: @equipment_component, status: :created, location: @equipment_component
        else
          render json: @equipment_component.errors, status: :unprocessable_entity
        end
      end

      def update
        if @equipment_component.update(equipment_component_params)
          render json: @equipment_component
        else
          render json: @equipment_component.errors, status: :unprocessable_entity
        end
      end

      private

      def set_equipment_component
        @equipment_component = EquipmentComponent.find(params[:id])
      end

      def equipment_component_params
        params.require(:equipment_component).permit(:id, :name, :serial_no, :equipment_item_id)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mks_edm-1.0.5 app/controllers/mks/edm/equipment_components_controller.rb
mks_edm-1.0.4 app/controllers/mks/edm/equipment_components_controller.rb
mks_edm-1.0.2 app/controllers/mks/edm/equipment_components_controller.rb
mks_edm-1.0.1 app/controllers/mks/edm/equipment_components_controller.rb