Method: Tagalong::Tagger::InstanceMethods#create_tag

Defined in:
lib/tagalong/tagger.rb

#create_tag(tag_name) ⇒ Object



23
24
25
26
27
# File 'lib/tagalong/tagger.rb', line 23

def create_tag(tag_name)
  raise Tagalong::TagAlreadyInUse, "A tag already exists with the name '#{tag_name}'" if tagalong_tags.find_by_name(tag_name).present?
  raise Tagalong::TagCannotBeBlank, "A tag cannot have a blank name" if tag_name.blank?
  TagalongTag.create!(:tagger_id => self.id, :tagger_type => self.class.to_s, :name => tag_name)
end