Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveResource::Base.exists? compares string with integer

#299

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

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [e7a305f08d8f72f81449e1d8934fba31f038ad88]) Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)

    http://github.com/rails/rails/co...

    June 3rd, 2008 @ 03:58 AM

  2. Repository
    Repository

    (from [db1cac2f42147ba16da56d2d0c3c8756b7828d8e]) Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)

    http://github.com/rails/rails/co...

    June 3rd, 2008 @ 04:11 AM

  3. alaittin
    alaittin
    • Tag set to activeresource, bug, patch, tiny
    • Assigned user set to Repository

    November 4th, 2008 @ 03:09 PM

  4. alaittin
    alaittin
    • Assigned user cleared.

    November 4th, 2008 @ 03:10 PM