Friendly URLs in Ruby on Rails

June 15, 2009
A quick and easy way to add friendly url's in ruby on rails

in the Model put :

   1  def to_param
   2    id.to_s+'-'+title.downcase.gsub(' ', '-')
   3  end
   4  # note - title to be replaced with relevant column name

so now instead of :

http://www.savantis.co.uk/savantis/blog_article/19

you would get :

www.savantis.co.uk/savantis/blog_article/19-friendly-urls-in-ruby-on-rails

Bookmark and Share

Why Ruby on Rails ?

Ruby On Rails Logo
Find out how Ruby on Rails could save your company time & money!

Latest News

PCG RLM Thursday 25 March 2010

March 1, 2010
Things are shaping up for a local PCG meeting in Newcastle Upon Tyne
Read more »

Open Source ?

open source technology
Find out why savantis use open source technology & how this can benefit you !

Latest Tweet