Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Inserting ID to URL...

Replytotopic

Inserting ID to URL

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

I am creating a tinyurl clone based off of Robby Rusell’s Rubyurl. The purpose of the app is to not only shrink the size of a URL, but to also track how the new URL is being used. For example, if I wanted to create a new tiny URL to be used on behalf of one of my clients, I’d want to somehow pass a client ID to the new tiny URL so that it would look something like this:
www.rubyurlclone.com/clientID/random_token

Question: how do I insert that clientID? Having a hard time wrapping my brain around this one.

Thanks!
n’cho

 
Profile

Authority 12
Posting Rating 100
Sign in to rate this post

Well, doing anything with how your routes are generated would be handled in the routes.rb file.
A simple example(not realistic without more detailed info):

in routes.rb:
map.connect ’:clientID/:random_token ’, :controller => ‘my_controller’, :action => ‘my_action’

in view:
link_to ‘my_link’, :controller => ‘my_controller’, :action => ‘my_action’, :clientID => params[:client_id], :random_token => params[:random_token]

I hope this gets you headed down the right path.

 
Rj-blogshot

Authority 75
Posting Rating 97
Sign in to rate this post

I would map a root dispatch_controller to root (/) and glob the routes, the first being client id, the second being the generated token

Replytotopic

Other Recent Topics

Ask a Rails expert : how to execute the url from my controller

Ask a Rails expert : conditional action caching multiple mongrel clusters

Ask a Rails expert : Using like command in RoR

Ask a Rails expert : Apache ActionController:RoutingError

Ask a Rails expert : Multiple csv file upload based on data in a form

Ask a Rails expert : Exception error code

Ask a Rails expert : Tracking down an issue

Ask a Rails expert : Thread Vs Transaction

Ask a Rails expert : implementing whitelist plugin

Ask a Rails expert : Validation helper

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel