我有一个使用'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'
我想按一个人的姓氏订购。如您所见,我已将用户和人员包含在嵌套包含中。用户属于具有此声明的人:
belongs_to :person, :class_name => 'Party', :foreign_key => 'person_id', :with_disabled => true
Person 是 Party 的子类:
class Person < Party
派对有一个姓氏字段