On 30 May 2007, at 10:24, Gcompany wrote:

> how do we convert long url to short url in a rails app like
> snipurl.com or dwarfurl.com

You're asking on the wrong list, but here we go:

Create a model with these fields:
identifier
target_url

Each time a user enters a long url, add it to the table as the target  
url, and have a before_filter generate a unique hash-like identifier.  
Then have your routes include the identifier as the parameter. Just  
make sure your identifier is unique.

Basically you're just keeping a lookup table, very very easy.


Best regards

Peter De Berdt


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to