I have 4 classes - Patient, Doctor, Person, and Appointment. Patient and Doctor are subclasses of Person. Appointment belongs to Patient and belongs to Doctor.

I want to write an AR statement to sort appointments by the patient's last name and another to sort by the doctor's last name, as all appointments will be in a sortable table. I am a bit confused as to what to put in the "order" option of the AR find statement. If I put

```
:order => 'patient.last_name'

```

I get a mysql error - "Unknown column 'patient.last\_name' 
Which makes sense because there is no patient column, it is a patient\_id referring to a foreign "person" object. Of course I can sort by person.last\_name but I am not sure how to specify which type of person to sort by - doctor or patient.

I should also note that I am using the include option to eager load the patient and doctor.

**UPDATE**

There is only a person table and a appointments table. The patient and doctor inherit from the person. patients.last\_name will not work because there is no patients table.

The AR statement is:

```
find  :all,
                :include => [:doctor, :patient], 
                :order => 'something needs to go here'   

```

The 'something needs to go here' should be a statement to order by either the doctor's last name or the patient's last name.