Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix chat messages eager loading

  • Loading branch information...
commit 848dcc21849f7e93919648f1231f6f5ce9ead007 1 parent aa00b19
@ck3g authored
View
2  app/controllers/chat_messages_controller.rb
@@ -4,7 +4,7 @@ class ChatMessagesController < ApplicationController
def index
- @messages = ChatMessage.recent
+ @messages = ChatMessage.includes(:user).recent
respond_with @messages
end
View
2  app/models/chat_message.rb
@@ -4,7 +4,7 @@ class ChatMessage < ActiveRecord::Base
validates :body, :user_id, presence: true
def self.recent
- joins(:user).order("created_at Desc").limit(20).reverse
+ joins(:user).order("chat_messages.created_at DESC").limit(20).reverse
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.