This project is archived and is in readonly mode.
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
-
Repository June 3rd, 2008 @ 03:58 AM
- State changed from new to resolved
(from [e7a305f08d8f72f81449e1d8934fba31f038ad88]) Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)
-
Repository June 3rd, 2008 @ 04:11 AM
(from [db1cac2f42147ba16da56d2d0c3c8756b7828d8e]) Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)
-
alaittin November 4th, 2008 @ 03:09 PM
- Tag set to activeresource, bug, patch, tiny
- Assigned user set to Repository
-
alaittin November 4th, 2008 @ 03:10 PM
- Assigned user cleared.
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>