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 nice for handling duplicate slugs, etc. Here are some popular Github plugins -- does anyone have any experience with them?
Basically it seems like slugs are a totally solved problem, and I don't to reinvent the wheel.
In Rails you can use #parameterize
For example:
I use the following, which will
so, for example:
The main issue for my apps has been the apostrophes - rarely do you want the -s sitting out there on it's own.
We use to_slug
http://github.com/ludo/to_slug/tree/master
. Does everything we need it to do (escaping 'funky characters'). Hope this helps.EDIT: Seems to be breaking my link, sorry about that.
I modified it a bit to create dashes instead of underscores, if anyone is interested:
Here is what I use:
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:
Outputs:
-downcase-gsub-a-z1-9-chomp