#9 完了
This commit is contained in:
@@ -2,7 +2,11 @@ class TagsController < ApplicationController
|
||||
before_action :set_tags, only: %i[ show update destroy ]
|
||||
|
||||
def index
|
||||
@tags = Tag.all
|
||||
if params[:post].present?
|
||||
@tags = Tag.joins(:posts).where(posts: { id: params[:post] })
|
||||
else
|
||||
@tags = Tag.all
|
||||
end
|
||||
render json: @tags
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user