obdev/app/controllers/employments_controller.rb

32 lines
805 B
Ruby
Raw Normal View History

class EmploymentsController < ApplicationController
before_action :set_employment, only: [:edit, :update, :destroy]
def edit
# Edit view will be rendered
end
def update
if @employment.update(employment_params)
redirect_to participant_path(@employment.participant), notice: 'Employment was successfully updated.'
else
render :edit
end
end
def destroy
participant = @employment.participant
@employment.destroy
redirect_to participant_path(participant), notice: 'Employment was successfully removed.'
end
private
def set_employment
@employment = Employment.find(params[:id])
end
def employment_params
params.require(:employment).permit(:start_date, :end_date)
end
end