#64 バックエンドぼちぼち

This commit is contained in:
2025-10-09 23:47:08 +09:00
parent 19a17e7ba7
commit 915ebcc7cf
5 changed files with 71 additions and 1 deletions
@@ -78,6 +78,7 @@ class PostsController < ApplicationController
if post.save
post.resized_thumbnail!
post.tags = Tag.normalise_tags(tag_names)
post.tags = Tag.expand_parent_tags(post.tags)
render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }),
status: :created
else
@@ -111,6 +112,7 @@ class PostsController < ApplicationController
post = Post.find(params[:id].to_i)
tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names)
tags = Tag.expand_parent_tags(tags)
if post.update(title:, tags:, original_created_from:, original_created_before:)
render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }),
status: :ok