A Social Network in Rails: Elegant permalinks
In this post we’re adding permalinks to a Rails app using the friendly_id gem.
Let’s say you have a `User` and a `Photo` model in your app, and a user has_many :photos.
To add a permalink to a photo post that looks like this:
www.nice-pics.com/berners-lee/photos/my-first-site
Add friendly_id to your Gemfile:
gem “friendly_id”
Add the permalink schema to your routes.rb:
get “:user_id/photos/:photo_id”, to: “photos#show”, as: :photo_permalink
Now, add the friendly_id scheme to your User:
Read more »
