Class: TagDb::Model::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TagDb::Model::Tag
- Defined in:
- lib/tagutils/tags/models/tag.rb,
lib/tagutils/tags/models/tag_comp.rb
Instance Method Summary collapse
-
#key ⇒ Object
nb: only allow spaces and underscore inbetween; do NOT allow digit as first char for now.
- #on_before_save ⇒ Object
-
#title ⇒ Object
alias for name (depreciated api calls).
- #title=(value) ⇒ Object
Methods included from ClassMacros
Methods included from CategoryDb::ClassMacros
Instance Method Details
#key ⇒ Object
nb: only allow spaces and underscore inbetween;
do NOT allow digit as first char for now
12 13 |
# File 'lib/tagutils/tags/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_save ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/tagutils/tags/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 |
#title ⇒ Object
alias for name (depreciated api calls)
11 |
# File 'lib/tagutils/tags/models/tag_comp.rb', line 11 def title() name; end |
#title=(value) ⇒ Object
12 |
# File 'lib/tagutils/tags/models/tag_comp.rb', line 12 def title=(value) self.name = value; end |