Skip to content

Commit a5b1fae

Browse files
committed
allow deleting tags / removing from all linked pages
1 parent 3475a3b commit a5b1fae

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
class PageTagsController < ApplicationController
22
def remove
3+
# Params
4+
# {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove"
5+
return unless params.key?(:page_type) && params.key?(:slug)
6+
7+
PageTag.where(
8+
page_type: params[:page_type],
9+
slug: params[:slug],
10+
user_id: current_user.id
11+
).destroy_all
12+
13+
return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.'
314
end
415
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
get '/scratchpad', to: 'main#notes', as: :notes
100100

101-
get 'tag/remove'
101+
get 'tag/remove', to: 'page_tags#remove'
102102

103103
# Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks
104104
resources :documents

0 commit comments

Comments
 (0)