Include smiles when eager loading answers
This commit is contained in:
parent
7357e92865
commit
32e6975c28
|
@ -1,6 +1,6 @@
|
|||
class AnswerController < ApplicationController
|
||||
def show
|
||||
@answer = Answer.find(params[:id]).include(comments: [:user], question: [:user])
|
||||
@answer = Answer.find(params[:id]).include(comments: [:user, :smiles], question: [:user], smiles: [:user])
|
||||
@display_all = true
|
||||
|
||||
if user_signed_in?
|
||||
|
|
|
@ -9,6 +9,6 @@ module User::AnswerMethods
|
|||
answers
|
||||
.order(:created_at)
|
||||
.reverse_order
|
||||
.includes(comments: [:user], question: [:user])
|
||||
.includes(comments: [:user, :smiles], question: [:user], smiles: [:user])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,6 @@ module User::TimelineMethods
|
|||
|
||||
# @return [Array] the users' timeline
|
||||
def timeline
|
||||
Answer.where('user_id in (?) OR user_id = ?', friend_ids, id).order(:created_at).reverse_order.includes(comments: [:user], question: [:user], user: [:profile])
|
||||
Answer.where('user_id in (?) OR user_id = ?', friend_ids, id).order(:created_at).reverse_order.includes(comments: [:user, :smiles], question: [:user], user: [:profile], smiles: [:user])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue