Include smiles when eager loading answers

This commit is contained in:
Karina Kwiatek 2021-12-30 23:21:46 +01:00
parent 7357e92865
commit 32e6975c28
3 changed files with 3 additions and 3 deletions

View File

@ -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?

View File

@ -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

View File

@ -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