Class: WorldDB::Models::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WorldDB::Models::Tag
- Defined in:
- lib/worlddb/models/tag.rb
Instance Method Summary collapse
-
#key ⇒ Object
fix/todo: improve regex use [a-z] | [a-z][a-z0-9_ ]+[a-z0-9] to only allow spaces and underscore inbetween; do not allow digit as first char.
- #on_before_save ⇒ Object
Instance Method Details
#key ⇒ Object
fix/todo: improve regex use [a-z] | [a-z][a-z0-9_ ]+[a-z0-9] to only allow spaces and underscore inbetween; do not allow digit as first char
14 |
# File 'lib/worlddb/models/tag.rb', line 14 validates :key, :format => { :with => /^[a-z0-9_ ]{2,}$/, :message => 'expected two or more lowercase letters a-z or 0-9 digits or space or underscore' } |
#on_before_save ⇒ Object
21 22 23 24 |
# File 'lib/worlddb/models/tag.rb', line 21 def on_before_save # replace space with underscore e.g. north america becomes north_america and so on self.slug = key.gsub( ' ', '_' ) end |