Module: HasTags

Extended by:
ActiveSupport::Concern
Included in:
Integration, ReferenceEventConfiguration, Report
Defined in:
app/models/concerns/has_tags.rb

Instance Method Summary collapse

Instance Method Details

#associate_tag(tag_id) ⇒ Object



17
18
19
20
21
# File 'app/models/concerns/has_tags.rb', line 17

def associate_tag(tag_id)
  ressource_tag = ressource_tags.find_or_initialize_by(tag_id: tag_id)
  ressource_tag.save!
  ressource_tag
end

#associate_tags(tag_ids) ⇒ Object



23
24
25
26
27
# File 'app/models/concerns/has_tags.rb', line 23

def associate_tags(tag_ids)
  tag_ids.each do |tag_id|
    associate_tag(tag_id)
  end
end

#disassociate_tag(tag_id) ⇒ Object



29
30
31
32
# File 'app/models/concerns/has_tags.rb', line 29

def disassociate_tag(tag_id)
  ressource_tag = ressource_tags.find_by(tag_id: tag_id)
  ressource_tag&.destroy!
end