feat: D & D による上位タグ設定(#184) (#186)

Merge branch 'main' into feature/184

Merge branch 'main' into feature/184

Merge branch 'main' into feature/184

Merge branch 'main' into feature/184

Merge branch 'main' into feature/184

Merge remote-tracking branch 'origin/main' into feature/184

Merge branch 'main' into feature/184

Merge remote-tracking branch 'origin/main' into feature/184

Merge remote-tracking branch 'origin/main' into feature/184

Merge branch 'main' into feature/184

Merge branch 'main' into feature/184

#184

#184

#184

#184

#184

#184

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #186
This commit was merged in pull request #186.
This commit is contained in:
2026-01-07 03:26:05 +09:00
parent b309263df5
commit 5f306b04b8
7 changed files with 499 additions and 69 deletions
@@ -0,0 +1,27 @@
class TagChildrenController < ApplicationController
def create
return head :unauthorized unless current_user
return head :forbidden unless current_user.admin?
parent_id = params[:parent_id]
child_id = params[:child_id]
return head :bad_request if parent_id.blank? || child_id.blank?
Tag.find(parent_id).children << Tag.find(child_id) rescue nil
head :no_content
end
def destroy
return head :unauthorized unless current_user
return head :forbidden unless current_user.admin?
parent_id = params[:parent_id]
child_id = params[:child_id]
return head :bad_request if parent_id.blank? || child_id.blank?
Tag.find(parent_id).children.delete(Tag.find(child_id)) rescue nil
head :no_content
end
end
@@ -39,6 +39,17 @@ class TagsController < ApplicationController
end
def update
return head :unauthorized unless current_user
return head :forbidden unless current_user.member?
tag = Tag.find(params[:id])
attrs = { name: params[:name].presence,
category: params[:category].presence }.compact
tag.update!(attrs) if attrs.present?
render json: tag
end
def destroy
+5
View File
@@ -1,6 +1,11 @@
Rails.application.routes.draw do
resources :nico_tags, path: 'tags/nico', only: [:index, :update]
scope 'tags/:parent_id/children', controller: :tag_children do
post ':child_id', action: :create
delete ':child_id', action: :destroy
end
resources :tags do
collection do
get :autocomplete