You know, like myblog.com/posts/donald-e-knuth.
Should I do this with the built in parameterize method?
What about a plugin? I could imagine a plugin being n
Here is what I use:
class User < ActiveRecord::Base
before_create :make_slug
private
def make_slug
self.slug = self.name.downcase.gsub(/[^a-z1-9]+/, '-').chomp('-')
end
end
Pretty self explanatory, although the only problem with this is if there is already the same one, it won't be name-01 or something like that.
Example:
".downcase.gsub(/[^a-z1-9]+/, '-').chomp('-')".downcase.gsub(/[^a-z1-9]+/, '-').chomp('-')
Outputs: -downcase-gsub-a-z1-9-chomp