Module: Tags

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/tags.rb

Instance Method Summary collapse

Instance Method Details

#update_tags!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/concerns/tags.rb', line 13

def update_tags!
  unless tag_list.nil?
    self.tags = []
    used_tags = []
    tag_list.split(',').each do |name|
      name.strip!
      if !used_tags.include?(name) && name.present?
        used_tags << name
        tag = Tag.where(:ci_name => name.downcase).first
        if tag.nil?
          tag = Tag.create(:name => name)
        else
          tag.update(:name => name) unless name == tag.name
        end
        self.tags << tag
      end
    end
  end
end