次のような「will_paginate」を使用した AR クエリがあります。
paginate :all,
:page => criteria[:page],
:per_page => criteria[:per_page],
:include => { :user, :person },
:conditions => [conditions , criteria[:from_date], criteria[:to_date], criteria[:patient_id],criteria[:user_id]].concat(criteria[:actions]).concat(criteria[:types]).concat(criteria[:users]).concat(criteria[:statuses]).concat(criteria[:priorities]).compact,
:order => criteria[:order]
order 句でエラーが発生します。
Unknown column 'user.person.last_name' in 'order clause'
人の姓で注文しようとしています。ご覧のとおり、ネストされたインクルードに user と person を含めました。ユーザーは次のステートメントを持つ人に属しています:
belongs_to :person, :class_name => 'Party', :foreign_key => 'person_id', :with_disabled => true
Person は Party のサブクラスです。
class Person < Party
パーティーには last_name フィールドがあります