diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-13 18:03:43 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-13 18:03:43 +0100 |
| commit | a7791635aa98f012d35f97c3c5288494bbb28e38 (patch) | |
| tree | bad987e6b4d10ad2f7cd02e40658d464907595ee /app/controllers/concerns | |
| download | operum-a7791635aa98f012d35f97c3c5288494bbb28e38.tar.gz operum-a7791635aa98f012d35f97c3c5288494bbb28e38.zip | |
Initial commit
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'app/controllers/concerns')
| -rw-r--r-- | app/controllers/concerns/.keep | 0 | ||||
| -rw-r--r-- | app/controllers/concerns/taggable.rb | 17 |
2 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/controllers/concerns/.keep diff --git a/app/controllers/concerns/taggable.rb b/app/controllers/concerns/taggable.rb new file mode 100644 index 0000000..a9bda12 --- /dev/null +++ b/app/controllers/concerns/taggable.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# This module provides methods for controllers that have to deal with tag +# references (i.e. comments and things). This is closely tied to `TagReference` +# and its polymorphic `:taggable` column. +module Taggable + extend ActiveSupport::Concern + + # Update tag references for the given `object` with tags identified by the + # `ids` array. + def update_tags!(object:, ids:) + object.tag_references.destroy_all + return true unless ids + + ids.each { |id| TagReference.create!(tag_id: id, taggable: object) } + end +end |
