Getting nice URLs in a Rails App
I just discovered how easy it is to get rid of those silly ids in your URLs.
Just install friendly_id with
sudo gem install friendly_id
then run a little script/generate friendly_id to get your migration. Following that, just add this in your model(s) you need slugs for :
has_friendly_id :attribnute_you_wanna_slug, :use_slug => true
Rake some of this:
rake friendly_id:make_slugs MODEL=ModelName
And Voilà ! you’ve got a friendly ID which can be used in your URLs…
Isn’t it fun ??



