/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
app/controllers/clients_controller.rb
64 строки
2 KB
Dmitriy-Filatov
🧹 ФИНАЛЬНАЯ ЧИСТКА И БЕЗОПАСНОСТЬ
14 мар 2026, 03:59
14 мар 2026, 03:59
3f89264
Код
Авторство
О чём код?
class ClientsController < ApplicationController before_action :require_login before_action :set_client, only: %i[show edit update destroy] def index @clients = current_therapist.clients end def new @client = current_therapist.clients.build end def create @client = current_therapist.clients.build(client_params) if @client.save redirect_to clients_path, notice: "Клиент успешно создан" else render :new, status: :unprocessable_entity end end def show @client = current_therapist.clients.find(params[:id]) @dashboard = TherapistDashboardService.new(current_therapist) @recent_entries = @dashboard.client_recent_entries(@client, 5) end def update if @client.update(client_params) redirect_to client_path(@client), notice: "Данные обновлены" else render :edit, status: :unprocessable_entity end end def destroy @client.destroy redirect_to clients_path, notice: "Клиент удалён", status: :see_other end def search term = params[:query].to_s.strip if term.present? @clients = current_therapist.clients.where( "name ILIKE :q OR email ILIKE :q OR phone ILIKE :q", q: "%#{term}%" ) else @clients = current_therapist.clients end render partial: "clients/list", layout: false, locals: { clients: @clients } end private def set_client @client = current_therapist.clients.find(params[:id]) rescue ActiveRecord::RecordNotFound redirect_to clients_path, alert: "Клиент не найден" end def client_params params.require(:client).permit(:name, :email, :phone, :notes) end end