/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
app/controllers/sessions_controller.rb
71 строка
2 KB
Dmitriy-Filatov
test: завершение модульных тестов
27 мар 2026, 15:10
27 мар 2026, 15:10
5327127
Код
Авторство
О чём код?
class SessionsController < ApplicationController before_action :require_login before_action :set_client def index @sessions = @client.sessions.order(session_date: :desc) end def show @session = @client.sessions.find(params[:id]) end def new @session = @client.sessions.build(session_date: Time.current) end def create @session = @client.sessions.build(session_params) @session.therapist = Current.therapist if @session.save redirect_to client_path(@client), notice: "Сессия создана" else render :new, status: :unprocessable_entity end end def edit @session = @client.sessions.find(params[:id]) end def update @session = @client.sessions.find(params[:id]) if @session.update(session_params) redirect_to client_session_path(@client, @session), notice: "Сессия обновлена" else render :edit, status: :unprocessable_entity end end def destroy @session = @client.sessions.find(params[:id]) @session.destroy redirect_to client_path(@client), notice: "Сессия удалена" end private def set_client @client = Current.therapist.clients.find(params[:client_id]) end def session_params params.require(:session).permit(:session_date, :topic, :notes) end end # TEMP DEBUG def create @session = @client.sessions.build(session_params) @session.therapist = Current.therapist puts "=== SESSION CREATE DEBUG ===" puts "session_params: #{session_params.inspect}" puts "valid? #{@session.valid?}" puts "errors: #{@session.errors.full_messages}" if @session.errors.any? if @session.save redirect_to client_path(@client), notice: "Сессия создана" else render :new, status: :unprocessable_entity end end