ruby: user friendly url, slug

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

http://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,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

my tweets

September 2007
S S M T W T F
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Flickr Photos

RSS my shared links on google reader

  • An error has occurred; the feed is probably down. Try again later.
%d bloggers like this: