diff --git a/app/controllers/chat_channels_controller.rb b/app/controllers/chat_channels_controller.rb index ece534c39..85f7b9382 100644 --- a/app/controllers/chat_channels_controller.rb +++ b/app/controllers/chat_channels_controller.rb @@ -16,7 +16,9 @@ class ChatChannelsController < ApplicationController end end - def show; end + def show + @chat_messages = @chat_channel.messages.includes(:user).order("created_at DESC").limit(50) + end def create authorize ChatChannel diff --git a/app/views/chat_channels/show.json.jbuilder b/app/views/chat_channels/show.json.jbuilder index ed1e3c1ec..1c5176ff4 100644 --- a/app/views/chat_channels/show.json.jbuilder +++ b/app/views/chat_channels/show.json.jbuilder @@ -1,4 +1,4 @@ -json.messages @chat_channel.messages.order("created_at DESC").limit(50).reverse do |message| +json.messages @chat_messages.reverse do |message| json.user_id message.user_id json.username message.user.username json.profile_image_url ProfileImage.new(message.user).get(90)