diff --git a/backend/app/controllers/posts_controller.rb b/backend/app/controllers/posts_controller.rb index ba15e99..bf54551 100644 --- a/backend/app/controllers/posts_controller.rb +++ b/backend/app/controllers/posts_controller.rb @@ -314,7 +314,9 @@ class PostsController < ApplicationController def viewed return head :unauthorized unless current_user - current_user.viewed_posts << Post.find(params[:id]) + UserPostView.create_or_find_by!( + user: current_user, + post: Post.find(params[:id])) head :no_content end