From 86404bfb38d8249077118fe009e1e84c771c5a1a Mon Sep 17 00:00:00 2001 From: Junv Zhao Date: Wed, 2 Dec 2015 21:09:26 +0800 Subject: [PATCH] #43 include current_user"s posts into timeline --- app/controllers/api/v1/timeline_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/timeline_controller.rb b/app/controllers/api/v1/timeline_controller.rb index db1389a..5d58441 100644 --- a/app/controllers/api/v1/timeline_controller.rb +++ b/app/controllers/api/v1/timeline_controller.rb @@ -15,7 +15,8 @@ class Api::V1::TimelineController < Api::V1::ApplicationController def index if @current_user stars_ids = @current_user.stars.ids - posts_ids = TimelineSource.where(user_id: stars_ids).order(created_at: :desc).page(params[:page]).pluck(:post_id) + user_ids = stars_ids + [@current_user.id] + posts_ids = TimelineSource.where(user_id: user_ids).order(created_at: :desc).page(params[:page]).pluck(:post_id) render json: Post.find(posts_ids).index_by(&:id).slice(*posts_ids).values, each_serializer: EachPostSerializer else return most_liked