Trying to order my find by a related table through a related table…and
I get this error
PGError: ERROR: schema “placement” does not exist
: SELECT client_slots.“id” AS t0_r0, client_slots.“name” AS t0_r1,
client_slots.“facility_id” AS t0_r2, client_slots.“phone_number” AS
t0_r3, client_slots.“placement_id” AS t0_r4, client_slots.“gender” AS
t0_r5, client_slots.“handicapped_wheelchair” AS t0_r6,
client_slots.“handicapped_audible_visual” AS t0_r7, placements.“id” AS
t1_r0, placements.“intake_date” AS t1_r1, placements.“referral_date” AS
t1_r2, placements.“packet_received_date” AS t1_r3,
placements.“acceptance_date” AS t1_r4, placements.“admission_date” AS
t1_r5, placements.“discharge_date” AS t1_r6, placements.“processor_name”
AS t1_r7, placements.“discharged_to” AS t1_r8, placements.“client_id” AS
t1_r9, placements.“facility_id” AS t1_r10, placements.“case_manager_id”
AS t1_r11, placements.“packet_requested_date” AS t1_r12,
placements.“accepted” AS t1_r13, placements.“move_in_date” AS t1_r14,
placements.“recommendation” AS t1_r15, placements.“discharge_address” AS
t1_r16, placements.“transfer_to” AS t1_r17,
placements.“transfer_address” AS t1_r18, placements.“pltype” AS t1_r19,
placements.“estimated_discharge_date” AS t1_r20,
placements.“client_slot_id” AS t1_r21,
placements.“outpatient_client_slot_id” AS t1_r22 FROM client_slots LEFT
OUTER JOIN placements ON placements.id = client_slots.placement_id WHERE
((placement_id IS NOT NULL)) ORDER BY placement.client.lastname
My controller code looks like this…
@client_slots = ClientSlot.find(:all,
:conditions => cond.to_sql,
:include => 'placement',
:select => 'placement.client.lastname, placement.client.gov_id',
:order => 'placement.client.lastname')
If I remove the ‘:order =>’ part, it works fine but of course it’s not
ordered. When I add the ‘:order’ part, I get the error as indicated
above.
Why would the ‘placement’ (client_slot belongs_to :placement) work in
‘select’ but not ‘order’?
–
Craig W. [email protected]