Tagged as urls

edit delete favorite
Posted by eric on Nov 01, 2007
Rather than ugly urls like http://snipsnipe.com/snip/view/13 [snipsnipe.com], use the following hack to make more meaningful urls like http://snipsnipe.com/snip/view/13-pretty-urls-in-rails [snipsnipe.com].
class Code < ActiveRecord::Base
  def to_param
    "#{id}-#{full_name.gsub(/[^a-z1-9]+/i, '-')[0,40]}"
  end
end
 
Please submit any bugs/features and report abuse. Thanks!
Spacer
Spacer
Spacer
Top Tags
Spacer