2023-01-15 13:52:40 +01:00
|
|
|
class TeachersController < ApplicationController
|
|
|
|
before_action :set_teacher, only: %i[ show edit update destroy ]
|
|
|
|
|
|
|
|
# GET /teachers
|
|
|
|
def index
|
2023-01-15 13:59:06 +01:00
|
|
|
@teachers = Teacher.page params[:page]
|
2023-01-15 13:52:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# GET /teachers/1
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /teachers/new
|
|
|
|
def new
|
|
|
|
@teacher = Teacher.new
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /teachers/1/edit
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST /teachers
|
|
|
|
def create
|
|
|
|
@teacher = Teacher.new(teacher_params)
|
|
|
|
@teacher.member = current_member
|
|
|
|
|
|
|
|
if @teacher.save
|
|
|
|
redirect_to @teacher, notice: "Successfully created Teacher profile"
|
|
|
|
else
|
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PATCH/PUT /teachers/1
|
|
|
|
def update
|
|
|
|
if @teacher.update(teacher_params)
|
|
|
|
redirect_to @teacher, notice: "Teacher Profile was updated."
|
|
|
|
else
|
|
|
|
render :edit, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /teachers/1
|
|
|
|
def destroy
|
|
|
|
@teacher.destroy
|
|
|
|
redirect_to teachers_url, notice: "Teacher was successfully destroyed."
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
def set_teacher
|
|
|
|
@teacher = Teacher.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
|
|
def teacher_params
|
|
|
|
params.require(:teacher).permit(:name, :bio, :picture)
|
|
|
|
end
|
|
|
|
end
|