gregbell/active_admin — Issue #669: how to sort single table inheritance with belongs_to association.
Author: GutenYe
Created: 2011-10-24 08:28:15+00:00
State: open

\# models

```
class User < ActiveRecord::Base
end

class Student < User
end

class Teacher < User
end

class Project
belongs_to :student
belongs_to :teacher
end
```

\# app/admin/projects.rb

```

ActiveAdmin.register Project do

scope(:all, :default => true) { |projects| projects.includes :student, :teacher }

index do
column :student, :sortable => 'users.first_name'
column :teacher, :sortable => 'users.first_name'
end
end
```

can't work, because project.includes(:student, :teachers) includes all users at first time.

related: https://github.com/gregbell/active_admin/pull/623