Move logic to reject slugs that are just numbers into the slug module

This commit is contained in:
Neil Lalonde
2013-05-30 11:54:02 -04:00
parent 7d5c313456
commit b82a5dfd56
3 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,8 @@
module Slug
def self.for(string)
string.parameterize.gsub("_", "-")
slug = string.parameterize.gsub("_", "-")
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
end
end