Permalink
Browse files

fix chat messages eager loading

  • Loading branch information...
ck3g committed Mar 30, 2013
1 parent aa00b19 commit 848dcc21849f7e93919648f1231f6f5ce9ead007
Showing with 2 additions and 2 deletions.
  1. +1 −1 app/controllers/chat_messages_controller.rb
  2. +1 −1 app/models/chat_message.rb
@@ -4,7 +4,7 @@ class ChatMessagesController < ApplicationController
def index
- @messages = ChatMessage.recent
+ @messages = ChatMessage.includes(:user).recent
respond_with @messages
end
@@ -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

0 comments on commit 848dcc2

Please sign in to comment.