obdev/app/controllers/service_contracts_controlle...

43 lines
1.2 KiB
Ruby

class ServiceContractsController < ApplicationController
before_action :set_service_contract, only: [:edit, :update, :destroy]
def new
@service_contract = ServiceContract.new
end
def create
@service_contract = ServiceContract.new(service_contract_params)
if @service_contract.save
redirect_to participant_path(@service_contract.participant), notice: 'Service contract was successfully created.'
else
render :new
end
end
def edit
end
def update
if @service_contract.update(service_contract_params)
redirect_to participant_path(@service_contract.participant), notice: 'Service contract was successfully updated.'
else
render :edit
end
end
def destroy
@service_contract.destroy
redirect_to participant_path(@service_contract.participant), notice: 'Service contract was successfully destroyed.'
end
private
def set_service_contract
@service_contract = ServiceContract.find(params[:id])
end
def service_contract_params
params.require(:service_contract).permit(:start_date, :end_date, :participant_id, :vendor_id)
end
end