title: Generate URL in controller (rails)
body: <p>I have an action in my controller that renders JSON back to the client:</p>
  
  <pre><code>@data = [{label:"foo", url:"..."}, ...]
  
  render :json =&gt; @data
  </code></pre>
  
  <p>Basically "data" is an array of objects that each have a label and url property. The want to generate the URL on the server-side instead of handing this data to the client and having it iterate over it to generate the URL strings.</p>
  
  <p>If I could use the "link_to" method it would look like this:</p>
  
  <p>link_to "foo", {:action => 'some_action', :foobar => {}}</p>
  
  <p>Basically link to the /foobar/some_action</p>
  
  <p>What's the best way to generate the URL while in the controller since I don't have the handy "link_to" method?</p>