diff --git a/app/models/tag.rb b/app/models/tag.rb index acbc3281..5c54575f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -3,8 +3,8 @@ class Tag < ActiveRecord::Base has_many :taggings has_many :taggable, :through => :taggings - 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 = ", " + DELIMITER = ",".freeze # 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 = ", ".freeze # If database speed becomes an issue, you could remove these validations and # rescue the ActiveRecord database constraint errors instead. @@ -17,11 +17,11 @@ class Tag < ActiveRecord::Base # allow tags to be renamed later, you might want to use the # before_save callback instead. def before_create - self.name = name.downcase.strip.squeeze(" ") + self.name = name.downcase.strip.squeeze(' '.freeze) end def label - @label ||= name.gsub(' ', '-') + @label ||= name.tr(' '.freeze, '-'.freeze) end def to_s