細部
This commit is contained in:
@@ -30,7 +30,7 @@ class PostsController < ApplicationController
|
|||||||
viewed = current_user&.viewed?(post) || false
|
viewed = current_user&.viewed?(post) || false
|
||||||
|
|
||||||
render json: (post
|
render json: (post
|
||||||
.as_json(include: { tags: { only: [:id, :name, :category] } })
|
.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } })
|
||||||
.merge(viewed: viewed))
|
.merge(viewed: viewed))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class PostsController < ApplicationController
|
|||||||
viewed = current_user&.viewed?(post) || false
|
viewed = current_user&.viewed?(post) || false
|
||||||
|
|
||||||
render json: (post
|
render json: (post
|
||||||
.as_json(include: { tags: { only: [:id, :name, :category] } })
|
.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } })
|
||||||
.merge(viewed: viewed))
|
.merge(viewed: viewed))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class PostsController < ApplicationController
|
|||||||
if post.save
|
if post.save
|
||||||
post.resized_thumbnail!
|
post.resized_thumbnail!
|
||||||
post.tags = Tag.normalise_tags(tags_names)
|
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
|
status: :created
|
||||||
else
|
else
|
||||||
render json: { errors: post.errors.full_messages }, status: :unprocessable_entity
|
render json: { errors: post.errors.full_messages }, status: :unprocessable_entity
|
||||||
@@ -96,7 +96,7 @@ class PostsController < ApplicationController
|
|||||||
post = Post.find(params[:id].to_i)
|
post = Post.find(params[:id].to_i)
|
||||||
tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names)
|
tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names)
|
||||||
if post.update(title:, tags:)
|
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
|
status: :ok
|
||||||
else
|
else
|
||||||
render json: post.errors, status: :unprocessable_entity
|
render json: post.errors, status: :unprocessable_entity
|
||||||
|
|||||||
Reference in New Issue
Block a user