I am browsing some resources through a simple API that returns JSON. I would like to indicate the path to each of the resources so that the consumer does not create them. An example of the 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'
}}
];
To create the URL, I would like to continue to use helpers and not pollute the models with such information. Is there any way to do this? Or am I better off just pasting this into a model?
source
share