I have this model:
class User < ActiveRecord::Base has_many :customers, -> { order('customers.name ASC') } has_many :stores, -> { order('company_stores.id ASC').uniq }, through: :customers end
When i try
user.stores
I have this error:
PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
because Rails does SELECT DISTINCT of company_stores.* , but customers.name also appears in ORDER BY
Should I refuse an order in associations?
ruby-on-rails
John smith
source share