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 User.all.to_json
:
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'
}}
];
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?