This commit is contained in:
2026-05-01 05:01:13 +09:00
parent fa8eb66535
commit 9b1df20ab5
5 changed files with 22 additions and 14 deletions
+5 -5
View File
@@ -127,7 +127,7 @@ class PostsController < ApplicationController
post = Post.new(title:, url:, thumbnail_base: nil, uploaded_user: current_user,
original_created_from:, original_created_before:)
post.thumbnail.attach(thumbnail)
post.thumbnail.attach(thumbnail) if thumbnail.present?
ApplicationRecord.transaction do
post.save!
@@ -149,8 +149,8 @@ class PostsController < ApplicationController
render json: PostRepr.base(post), status: :created
rescue ArgumentError => e
render json: { errors: [e.message] }, status: :unprocessable_entity
rescue ActiveRecord::RecordInvalid
render json: { errors: post.errors.full_messages }, status: :unprocessable_entity
rescue ActiveRecord::RecordInvalid => e
render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity
rescue Tag::NicoTagNormalisationError
head :bad_request
end
@@ -204,8 +204,8 @@ class PostsController < ApplicationController
render json:, status: :ok
rescue ArgumentError => e
render json: { errors: [e.message] }, status: :unprocessable_entity
rescue ActiveRecord::RecordInvalid
render json: post.errors, status: :unprocessable_entity
rescue ActiveRecord::RecordInvalid => e
render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity
rescue Tag::NicoTagNormalisationError
head :bad_request
end
+1 -1
View File
@@ -56,7 +56,7 @@ class Post < ApplicationRecord
def snapshot_tag_names = tags.joins(:tag_name).order('tag_names.name').pluck('tag_names.name')
def snapshot_parent_post_ids = parents.order(:parent_post_id).pluck(:parent_post_id)
def snapshot_parent_post_ids = parents.order(:id).pluck(:id)
def related limit: nil
ids = post_similarities.order(cos: :desc)