This project is archived and is in readonly mode.

#299 ✓resolved
Wes Oldenbeuving

ActiveResource::Base.exists? compares string with integer

Reported by Wes Oldenbeuving | June 2nd, 2008 @ 02:11 PM

In #11062, a patch was applied which made the exists? method more efficient by doing a HEAD request and comparing HTTP status codes, instead of doing a GET and checking if it is a resource.

The code compares the response status code with the integer 200, expecting the response status code to be an integer as well. In the tests, this is the case. My local setup (rails 2.1.0 + mongrel 1.1.5 on Linux) returns a String here and thus fails.

The attached patch fixes the problem by casting the response code to an integer prior to comparing it with the integer status 200.

Relevant code before patch:

response = connection.head(path, headers)

response.code == 200

Relevant code after patch:

response = connection.head(path, headers)

response.code.to_i == 200

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages