Actions With Dashes - Updated
2009-04-02
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.
blog comments powered by Disqus