title: How do I add extra data to ActiveRecord records being serialized to JSON in Rails?
body: <p>I'm exposing some resources via a simple API that returns JSON.  I would like to inject the path to each of the resources so that the consumer need not construct them.  Example of desired output for something like <code>User.all.to_json</code>:</p>
  
  <pre><code>users: [
    {user: {
      id: 1,
      name: 'Zaphod',
      url: 'http://domain.com/users/1.json'
    }},
    {user: {
      id: 2,
      name: 'Baron Munchausen',
      url: 'http://domain.com/users/2.json'
    }}
  ];
  </code></pre>
  
  <p>In order to generate the URL I'd like to continue using the helpers and not pollute the models with this kind of information.  Is there a way to do this?  Or am I better off just putting this into the model?</p>