Class: Tag

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tag.rb

Constant Summary collapse

DELIMITER =

Controls how to split and join tagnames from strings. You may need to change the validates_format_of parameters if you change this.

","
JOIN_DELIMITER =
", "

Instance Method Summary collapse

Instance Method Details

#before_createObject

Callback to strip extra spaces from the tagname before saving it. If you allow tags to be renamed later, you might want to use the before_save callback instead.



19
20
21
# File 'app/models/tag.rb', line 19

def before_create
  self.name = name.downcase.strip.squeeze(" ")
end

#labelObject



23
24
25
# File 'app/models/tag.rb', line 23

def label
  @label ||= name.gsub(' ', '-')
end

#to_sObject



27
28
29
# File 'app/models/tag.rb', line 27

def to_s
  name
end