This commit is contained in:
2025-05-25 14:53:37 +09:00
parent fa547bc62f
commit 41668fa894
8 changed files with 209 additions and 141 deletions
+2 -2
View File
@@ -18,13 +18,13 @@ class PostsController < ApplicationController
else
@posts = Post.all
end
render json: @posts
render json: @posts.as_json(include: { tags: { only: [:id, :name, :category] } })
end
# GET /posts/1
def show
@post = Post.includes(:tags).find(params[:id])
render json: @post.as_json(include: { tags: { only: [:id, :name] } })
render json: @post.as_json(include: { tags: { only: [:id, :name, :category] } })
end
# POST /posts