2013-02-05 14:16:51 -05:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
module Slug
|
|
|
|
|
|
|
|
def self.for(string)
|
2013-06-02 19:08:34 -04:00
|
|
|
slug = string.gsub("'", "").parameterize
|
|
|
|
slug.gsub!("_", "-")
|
2013-05-30 11:54:02 -04:00
|
|
|
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|