From cbade1cd83916230953aa971644a4b850446bd77 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 21 Jul 2025 05:12:17 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B4=B0=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/controllers/posts_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/app/controllers/posts_controller.rb b/backend/app/controllers/posts_controller.rb index 60f3577..f46c48c 100644 --- a/backend/app/controllers/posts_controller.rb +++ b/backend/app/controllers/posts_controller.rb @@ -30,7 +30,7 @@ class PostsController < ApplicationController viewed = current_user&.viewed?(post) || false render json: (post - .as_json(include: { tags: { only: [:id, :name, :category] } }) + .as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }) .merge(viewed: viewed)) end @@ -42,7 +42,7 @@ class PostsController < ApplicationController viewed = current_user&.viewed?(post) || false render json: (post - .as_json(include: { tags: { only: [:id, :name, :category] } }) + .as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }) .merge(viewed: viewed)) end @@ -64,7 +64,7 @@ class PostsController < ApplicationController if post.save post.resized_thumbnail! post.tags = Tag.normalise_tags(tags_names) - render json: post.as_json(include: { tags: { only: [:id, :name, :category] } }), + render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }), status: :created else render json: { errors: post.errors.full_messages }, status: :unprocessable_entity @@ -96,7 +96,7 @@ class PostsController < ApplicationController post = Post.find(params[:id].to_i) tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names) if post.update(title:, tags:) - render json: post.as_json(include: { tags: { only: [:id, :name, :category] } }), + render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }), status: :ok else render json: post.errors, status: :unprocessable_entity