how do we convert long url to short url in a rails app like snipurl.com or dwarfurl.com Please help THanks --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, This is more of a general question or Rails question than Rails Spinoffs. Next time, consider posting to RubyOnRails-Talk instead. Gcompany a écrit :> how do we convert long url to short url in a rails app like > snipurl.com or dwarfurl.com1) Devise a short ID generation algorithm (can be anything, really) 2) Store a mapping from the short, generated ID to the long URL you want in a DB table somewhere. 3) Provide a controller that takes the short ID as a parameter, reads the DB table and issues a redirect to the long URL. Now, unless you''re on a GET access with plenty of arguments inline, Rails app URLs are usually darn short. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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.comYou''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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---