Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow deleting tags / removing from all linked pages
  • Loading branch information
drusepth committed Oct 5, 2021
commit a5b1faecb63a0b27ceb8fc3e39a8d0662872276e
11 changes: 11 additions & 0 deletions app/controllers/page_tags_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
class PageTagsController < ApplicationController
def remove
# Params
# {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove"
return unless params.key?(:page_type) && params.key?(:slug)

PageTag.where(
page_type: params[:page_type],
slug: params[:slug],
user_id: current_user.id
).destroy_all

return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.'
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

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

get 'tag/remove'
get 'tag/remove', to: 'page_tags#remove'

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