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

Amazon S3 in AWS Management Console Demo

June 10, 2010
Amazon announce that the AWS Management Console now provides a simple and intuitive web interface for managing your Amazon S3 resources.
Read more »

Open Source ?

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

Latest Tweet