On 05/10/2011 05:58 PM, Matt Wagner wrote:
Hi, sorry for replying now when patch is already in for a long time. I
I'm attaching a patch that implements feature #1451 - RESTful
controllers. The scope here was just to update PoolsController,
InstancesController, and DeploymentsController.
There were some oddities along the process, since some of what we do
doesn't map up with the REST ideals. So please note (and feel free to
propose alternatives for) the following:
* I implemented destroy methods, but nothing calls them yet. The destroy
* methods will accept params[:id] or an array in params[:ids], so we
* could replace the multi_destroy methods with destroy. I have not done
* so yet because Rails won't generate an instance URL this way, so it
* would require some client-side wrangling. multi_destroy is a
* collection method in routes.rb, but destroy is expected to be an
* instance method and requires that the ID be passed in. In our case,
* the id is an array of whatever the user selects. For now I've just
* left multi_destroy, but this feels like needless duplication.
* I didn't link to the edit page for Instances or Deployments. Right
* now, the user is only permitted to edit the name attribute for these,
* since changing any other attributes would be harmful (or, at best,
* ineffective). I have what feels like a crude setup here to strip out
* non-permitted attributes. It seems like attr_protected would help
* here, but it's really going to get much more complicated -- other
* components of the app can use this method to, for example, mark the
* status of an instance as having changed, but a user shouldn't be able
* to. I'm all ears if someone sees a cleaner way to do this.
I think it would be better/cleaner to have both methods:
- multi_destroy for deleting multiple objects
- destroy for deleting single object
In this way this doesnt' violates default rails/rest 'delete route.
The short version is that there are currently no user-facing changes
this patch, but it does afford us a RESTful interface for Pools,
Instances, and Deployments.
aeolus-devel mailing list