Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11062 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

[PATCH] ActiveResource should use the HEAD method when checking whether a resource exists

Reported by: bscofield Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveResource Version: edge
Severity: normal Keywords: activeresource exists head
Cc:

Description

Currently, an ARes model GETs the resource when checking existence:

Person.exists?(1) #=> GET /people/1.xml

The appropriate method to use is actually HEAD, since all you really need is the status code - 200 if it exists, 404 if not. The attached patch adds this functionality, and updates the various aspects of the tests (and mocks) to support it.

Note: as Rails currently stands, HEAD requests are treated as GETs - so this change shouldn't break anybody's RESTful routing. It will, however, increase efficiency, since only the headers are passed back (this is especially helpful if you have large models).

Attachments

use_head_method_in_activeresource_base_exists.patch (4.0 kB) - added by bscofield on 02/09/08 05:57:27.

Change History

02/09/08 05:57:27 changed by bscofield

  • attachment use_head_method_in_activeresource_base_exists.patch added.

02/09/08 22:21:58 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

(In [8827]) Use HEAD instead of GET inside exists? Closes #11062 [bscofield]