commission update -> change route under settings
This commit is contained in:
75
app/controllers/settings/commissioners_controller.rb
Normal file
75
app/controllers/settings/commissioners_controller.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
class Settings::CommissionersController < ApplicationController
|
||||
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
def index
|
||||
@commissioners = Commissioner.all.order("id asc")
|
||||
end
|
||||
|
||||
# GET /commissioners/1
|
||||
# GET /commissioners/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /commissioners/new
|
||||
def new
|
||||
@commissioner = Commissioner.new
|
||||
@employee = Employee.all.order('name asc')
|
||||
end
|
||||
|
||||
# GET /commissioners/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /commissioners
|
||||
# POST /commissioners.json
|
||||
def create
|
||||
@commissioner = Commissioner.new(commissioner_params)
|
||||
@commissioner.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
format.html { redirect_to settings_commissioners_path , notice: 'Commissioner was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @commissioner }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /commissioners/1
|
||||
# PATCH/PUT /commissioners/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commissioner.update(commissioner_params)
|
||||
format.html { redirect_to settings_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @commissioner }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /commissioners/1
|
||||
# DELETE /commissioners/1.json
|
||||
def destroy
|
||||
@commissioner.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_commissioners_path , notice: 'Commissioner was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commissioner
|
||||
@commissioner = Commissioner.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name,:emp_id,:created_by,:commission_id,:joined_date,:resigned_date, :is_active)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user