Back in October 2005, I wrote an article entitled Actions with Dashes. This article is perfectly obsolete and uses a trick instead of the router as it was intended.

Let’s say you want an action where the URL is http://myproject.com/contact-us. The best way to do that currently is to use Rails’ router:

config/routes.rb
1 map.contact_us "/contact-us", :controller => "pages", :action => "show", :page => "contact_us"

app/controllers/pages_controller.rb
1 class PagesController < ActionController
2   def show
3     render :action => params[:page]
4   end
5 end

The PagesController above is also good for any other static pages you want to serve on your site.

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on