ruby: user friendly url, slug

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,

Advertisement

Leave a Reply

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

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com 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

@kamalapur over bridge

@kamalapur station

cox's bazaar trip oct 09

cox's bazaar trip oct 09

cast ur vote!

More Photos
Follow

Get every new post delivered to your Inbox.