このコミットが含まれているのは:
@@ -33,13 +33,15 @@ class NicoTagsController < ApplicationController
|
||||
return render_bad_request('ニコニコ・タグを指定してください.') unless tag.nico?
|
||||
|
||||
linked_tag_names = params[:tags].to_s.split
|
||||
linked_tags = Tag.normalise_tags!(linked_tag_names, with_tagme: false,
|
||||
with_no_deerjikist: false)
|
||||
if linked_tags.any? { |t| t.nico? }
|
||||
return render_unprocessable_entity('ニコニコ・タグ同士は連携できません.', field: :tags)
|
||||
end
|
||||
linked_tags = nil
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
linked_tags = Tag.normalise_tags!(linked_tag_names, with_tagme: false,
|
||||
with_no_deerjikist: false)
|
||||
if linked_tags.any? { |t| t.nico? }
|
||||
raise Tag::NicoTagNormalisationError
|
||||
end
|
||||
|
||||
TagVersioning.record_tag_snapshots!(linked_tags, created_by_user: current_user)
|
||||
|
||||
tag.linked_tags = linked_tags
|
||||
@@ -49,5 +51,21 @@ class NicoTagsController < ApplicationController
|
||||
end
|
||||
|
||||
render json: tag.linked_tags.map { |t| TagRepr.base(t) }, status: :ok
|
||||
rescue Tag::NicoTagNormalisationError
|
||||
render_validation_error fields: { tags: ['ニコニコ・タグ同士は連携できません.'] }
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render_nico_tag_form_record_invalid e.record
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_nico_tag_form_record_invalid record
|
||||
if record.is_a?(TagName) || record.is_a?(Tag)
|
||||
render_validation_error fields: { tags: record.errors.full_messages.map { |message|
|
||||
"タグ名 “#{ record.name }”: #{ message }"
|
||||
} }
|
||||
else
|
||||
render_validation_error record
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする