From 2b593cce93aa045ff784be44a5912cec7a6c8f90 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sat, 31 Jan 2026 20:12:11 +0530 Subject: [PATCH] fix(chat): include user object in POST /api/chat response - Changed create action to render show.rabl view instead of raw model - Response now includes nested user object with name field - Matches format returned by GET /api/chat (index action) - Fixes 'Unknown' sender name issue for sent messages Follows lobby chat pattern for consistent API response format. --- web/app/controllers/api_chats_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/api_chats_controller.rb b/web/app/controllers/api_chats_controller.rb index fa0b28111..0d537b87d 100644 --- a/web/app/controllers/api_chats_controller.rb +++ b/web/app/controllers/api_chats_controller.rb @@ -8,7 +8,12 @@ class ApiChatsController < ApiController @chat_msg = ChatMessage.create(current_user, @music_session, params[:message], params[:channel], params[:client_id], @target_user, @lesson_session) - respond_with_model(@chat_msg) + if @chat_msg.errors.any? + respond_with @chat_msg, status: :unprocessable_entity, layout: nil + else + @chat = @chat_msg + render "api_chats/show", :layout => nil, :status => 200 + end end def index