Class: TagDb::Model::Tag

Inherits:
ActiveRecord::Base show all
Defined in:
lib/tagutils/models/tag.rb

Instance Method Summary collapse

Methods included from ClassMacros

#has_many_tags

Methods included from CategoryDb::ClassMacros

#has_many_categories

Instance Method Details

#keyObject

nb: only allow spaces and underscore inbetween;

do NOT allow digit as first char for now


12
13
# File 'lib/tagutils/models/tag.rb', line 12

validates :key,  :format => { :with    => /^([a-z]|[a-z][a-z0-9_ ]*[a-z0-9])$/,
:message => 'expected one or more lowercase letters a-z or 0-9 digits or space or underscore' }

#on_before_saveObject



22
23
24
25
26
27
28
# File 'lib/tagutils/models/tag.rb', line 22

def on_before_save
  # replace space with dash e.g. north america becomes north-america and so on
  self.slug = key.gsub( ' ', '-' )
 
  ## if name is empty auto fill w/ key
  self.name = key   if name.blank?
end

#titleObject

alias for name (remove! add depreciated api call) ?? why? why not??



34
# File 'lib/tagutils/models/tag.rb', line 34

def title()       name;              end

#title=(value) ⇒ Object



35
# File 'lib/tagutils/models/tag.rb', line 35

def title=(value) self.name = value; end