These really are anemic too

This commit is contained in:
David Heinemeier Hansson
2025-04-06 18:16:47 +02:00
parent cc0c88d999
commit 21211cedca
+1 -10
View File
@@ -10,19 +10,10 @@ module Bubble::Taggable
def toggle_tag_with(title)
tag = bucket.account.tags.find_or_create_by!(title: title)
transaction { tagged_with?(tag) ? untagging(tag) : tagging(tag) }
transaction { tagged_with?(tag) ? taggings.destroy_by(tag:) : taggings.create(tag:) }
end
def tagged_with?(tag)
tags.include? tag
end
private
def tagging(tag)
taggings.create tag: tag
end
def untagging(tag)
taggings.destroy_by tag: tag
end
end