hasan's blog (বল্গ)

work for fun!!!

ruby: user friendly url, slug

leave a comment »

i had a requirement to create user friendly url, like the following example -

www.domain.com/user-friendly-url,

so you know i am getting more and more passion over ruby stuff, http://blood.we4tech.com just brought me on rails again.

here is the ruby code snap, which removes all kinda illegal characters and  creates a nice slug -

title.gsub(/[^[:alnum:]]+/i, “_”)

thanks  push.cx for quick nice example

best wishes,

Written by nhm tanveer hossain khan

September 5, 2007 at 7:47 am

Posted in Ruby

Leave a Reply