Ruby On Rails: Meaningful (and beautiful) URLs
This tutorial is going to take you through what it takes to make your URLs easy to remember and meaningful. Great examples of sites that implement this well are Flickr and Delicious. We are going to first take a look at the Routes framework in the Action Controller and see what options it gives us. I am going to assume basic knowledge of Ruby on Rails and am going to assume that your are starting with a newly generated application. (NOTE: I am using Rails 2.1.1)
Routes in Ruby on Rails allow you to map incoming URLs to specific controllers, actions, and parameters in your application. Routes are written in pure ruby and can be found in the file config/routes.rb in your application’s root directory. Upon generating a new application using rails appname, some default routes are created for you as shown below (comments have been removed):
1 2 3 4 ActionController::Routing::Routes.draw do |map| map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end