I have a route in my application that is like this:
/deployments/:id/logs.json
It is used to retrieve logs for a specific deployment. On my client code, based in ActiveResource I have this:
logs = Deployment.find(deployment.id).get(:logs, opts)
Where opts is some parameters that I send via query string.
The problem with this code is that it breaks the request in two. The Deployment#find
method requests:
GET /deployments/:id.json
And then, if this is found, a second request is sent:
GET /deployments/:id/logs.json
Is it possible to skip the first query altogether using Rails 3 on the server and ActiveResource (current requirements for activeresource is >= 2.3.5 but I am fine with bumping it if needed)?
UPDATE: I think it works if I change:
logs = Deployment.find(deployment.id).get(:logs, opts)
to
logs = Deployment.new(:id => deployment.id).get(:logs, opts)
Any comments?