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.
This commit is contained in:
parent
d5772ce1d7
commit
2b593cce93
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue