This commit is contained in:
@@ -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
|
||||
|
||||
+10
-10
@@ -1,4 +1,14 @@
|
||||
Rails.application.routes.draw do
|
||||
get 'tags/autocomplete', to: 'tags#autocomplete'
|
||||
post 'posts/:id/viewed', to: 'posts#viewed'
|
||||
delete 'posts/:id/viewed', to: 'posts#unviewed'
|
||||
get 'preview/title', to: 'preview#title'
|
||||
get 'preview/thumbnail', to: 'preview#thumbnail'
|
||||
get 'wiki/title/:title', to: 'wiki_pages#show_by_title'
|
||||
get 'wiki/:id', to: 'wiki_pages#show'
|
||||
post 'wiki', to: 'wiki_pages#create'
|
||||
put 'wiki/:id', to: 'wiki_pages#update'
|
||||
|
||||
resources :posts
|
||||
resources :ip_addresses
|
||||
resources :nico_tag_relations
|
||||
@@ -15,16 +25,6 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
get 'tags/autocomplete', to: 'tags#autocomplete'
|
||||
post 'posts/:id/viewed', to: 'posts#viewed'
|
||||
delete 'posts/:id/viewed', to: 'posts#unviewed'
|
||||
get 'preview/title', to: 'preview#title'
|
||||
get 'preview/thumbnail', to: 'preview#thumbnail'
|
||||
get 'wiki/title/:title', to: 'wiki_pages#show_by_title'
|
||||
get 'wiki/:id', to: 'wiki_pages#show'
|
||||
post 'wiki', to: 'wiki_pages#create'
|
||||
put 'wiki/:id', to: 'wiki_pages#update'
|
||||
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
||||
|
||||
Reference in New Issue
Block a user