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.

Couldn't find Class with ID=#num

#850

In Rails 2.1, in my controller I have:

Client.find(params[:id], :joins => [:address, :mailing_address])

where the mailing_address association is possibly nil. Doing a find on a client with this code where the client's mailing address is nil, it says:

Couldn't find Client with ID=1

This is misleading, since the Client with the id of 1 DOES exist.

Reported by Ryan Bigg · August 18th, 2008 @ 01:53 AM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Chris Barnett
    Chris Barnett

    The :joins parameter adds an INNER JOIN clause to the query, which causes the database to filter out clients without a mailing_address.

    Replacing :joins with :include gives the desired behaviour (by using a LEFT JOIN clause).

    The error might seem misleading, but there's no way rails could tell the difference between a missing mailing_address and a missing client when :joins is used.

    This ticket should probably be closed.

    August 18th, 2008 @ 05:04 AM

  2. Pratik
    Pratik
    • State changed from new to invalid

    August 18th, 2008 @ 11:52 AM