From d1af1cac6a2fb5bb38a0a932966556f21749135b Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sat, 18 Feb 2023 16:51:32 +1100 Subject: [PATCH] Allow post tags to be removed --- app/repos/post_repo.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/repos/post_repo.rb b/app/repos/post_repo.rb index 143a902..4cdfa44 100644 --- a/app/repos/post_repo.rb +++ b/app/repos/post_repo.rb @@ -45,6 +45,12 @@ module Adamantium end end + def remove_tag(post_id:, tag:) + tag = posts.tags.where(label: tag).one + + posts.post_tags.where(post_id: post_id, tag_id: tag[:id]).changeset(:delete).commit if tag + end + def post_listing(limit: nil) posts .where(post_type: "post")