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