I have the following line in my ActiveRecord model:
class Record < ActiveRecord::Base
has_many :users, :through => :record_users, :uniq => true, :order => "record_users.index ASC"
This is intended to enable me to read out record.users in a way that I order using an index field in the record_users model.
The problem is that this fails on PostgreSQL with the following error:
ActionView::TemplateError (PGError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Is there a way to fix the statement to make it work?