Get action with member url using ActiveResource

I have a route in my application that looks like this:

/deployments/:id/logs.json

Used to retrieve logs for a specific deployment. In my ActiveResource-based client code, I have the following:

logs = Deployment.find(deployment.id).get(:logs, opts)

In cases where opts are some parameters that I send via the query string.

The problem with this code is that it interrupts the request in half. The method Deployment#findrequests:

GET /deployments/:id.json

And then, if it is found, a second request is sent:

GET /deployments/:id/logs.json

Is it possible to skip the first request altogether using Rails 3 on the server and ActiveResource (current requirements for activeresource => 2.3.5, but am I fine with hits, if necessary)?

. , , :

logs = Deployment.find(deployment.id).get(:logs, opts)

logs = Deployment.new(:id => deployment.id).get(:logs, opts)

?

+5
1

, :

logs = Deployment.find(deployment.id).get(:logs, opts)

logs = Deployment.new(:id => deployment.id).get(:logs, opts)
+4

All Articles