/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
app/controllers/therapists_controller.rb
61 строка
2 KB
Dmitriy-Filatov
style: синхронизация страницы регистрации с дизайн-системой
25 фев 2026, 15:44
25 фев 2026, 15:44
086635d
Код
Авторство
О чём код?
class TherapistsController < ApplicationController skip_before_action :require_login, only: [ :new, :create ] before_action :set_therapist, only: %i[ show edit update destroy ] def index @therapists = [ current_therapist ] end def show end def new @therapist = Therapist.new end def edit end def create @therapist = Therapist.new(therapist_params) # Проверка на пустые поля ДО валидации модели if therapist_params[:name].blank? || therapist_params[:email].blank? || therapist_params[:password].blank? flash.now[:alert] = "Заполните все поля" return render :new, status: :unprocessable_entity end if @therapist.save session[:therapist_id] = @therapist.id redirect_to root_path, notice: "Добро пожаловать!" else render :new, status: :unprocessable_entity end end def update if @therapist.update(therapist_params) redirect_to @therapist, notice: "Терапевт обновлён" else render :edit, status: :unprocessable_entity end end def destroy @therapist.destroy! redirect_to therapists_path, notice: "Терапевт удалён", status: :see_other end private def set_therapist @therapist = current_therapist # Если вдруг params[:id] не совпадает с current_therapist — всё равно работаем только со своим # Это гарантирует, что никто не увидит чужого терапевта end def therapist_params params.require(:therapist).permit(:name, :email, :password, :password_confirmation) end end