This is a fairly open-ended question, and I'm just looking for the best possible avenue.
Users can post links with titles. And I want my URL's for SEO purposes to display those titles. Much in the same way I believe stackoverflow works.
So if the title is "My foobar just made out with my cat"
I would like the URL to be : www.website.com/posts/My-foobar-just-made-out-with-my-cat
Any ideas?
Thanks so much in advance!!
I used this in an old Rails 2.x app. There may be a better approach to scrubbing the title...
(goes in your model)
Hope this helps!
UPDATE
Comments on this answer indicated there is a new method available for Rails 3 users:
#parameterize
. The Rails API document for this method shows how it should be used (cut-n-paste):There's a really awesome plugin, FriendlyId which will handle all this for you. Loads of really clever features, including scopes and handling of 301 redirects on title change. This differs from stackoverflow and Brian's method in that the id isn't used in the url.