This commit is contained in:
2025-06-15 00:41:27 +09:00
parent 32ed235807
commit 50a9313525
2 changed files with 13 additions and 27 deletions
+3 -17
View File
@@ -1,14 +1,12 @@
class TagsController < ApplicationController
before_action :set_tags, only: %i[ show update destroy ]
def index
@tags =
tags =
if params[:post].present?
Tag.joins(:posts).where(posts: { id: params[:post] })
else
Tag.all
end
render json: @tags
render json: tags
end
def autocomplete
@@ -32,7 +30,7 @@ class TagsController < ApplicationController
end
def show
render json: @tag
render json: Tag.find(params[:id])
end
def create
@@ -43,16 +41,4 @@ class TagsController < ApplicationController
def destroy
end
private
# Use callbacks to share common setup or constraints between actions.
def set_tag
@tag = Tag.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def tag_params
params.expect(tag: [ :title, :body ])
end
end