aeolus-incubator / tim

Web application for managing virtual images to be deployed in the cloud
www.aeolusproject.org
MIT License
3 stars 6 forks source link

Fix issues with Rails API using <resource_id> format #54

Closed mtaylor closed 11 years ago

mtaylor commented 11 years ago

Rails uses foreign key in the database in order to associate resources. For example, in order to associate an existing template with a new BaseImage the format would be as follows:

<base_image>
    <template_id>1</template_id>

This goes against the resource principal as outlined here: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm @ 5.2.1.1 Resources and Resource Identifiers

Instead we want to use proper resource representations of the template. i.e.:

  <base_image>
    <template id=1 href="..."></template_id>

To do this I have taken the Filter created by jstransk which can be found here: https://github.com/aeolusproject/conductor/blob/d8c70dd9b90f87ea8bce364dca85fdb8e08e0de4/src/app/util/resource_link_filter.rb

I have not included tests for the filter since they are included in jstransk patchset. Eventually we want to pull out the rails API filters into a gem and share them across projects.

You can test this manually using the example added to the README

jguiditta commented 11 years ago

Martyn could you update the description with the examples? They seem to have not gone through in the formatting. If you are having trouble, you can just put them in a block with 3 single quotes, line break, and close again with 3 more quotes.

jguiditta commented 11 years ago

Ok, overall this looks pretty reasonable. Once you have looked through and responded to or addressed my comments, could you update either the commit or the issue to reference this pull request (either is fine by me).