This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user