我使用rails 2.3.5,will_paginate-2.3.15和postgress。 我有2个belongs_to's到同一张桌子。 如果我首先搜索属性然后搜索别名表属性,那么它会抛出异常。如果我在条件下颠倒顺序......
class House
belongs_to :owner, :class => "User"
belogns_to :creator, :class => "User"
end
House.paginate(
:page=>1,
:include=>[:creator, :owner],
:per_page=>20,
:conditions=>"houses.city ILIKE E'%new yo%' and owners_houses.architect ILIKE E'%tom%'")
加注
ActiveRecord::StatementInvalid: PGError: ERROR: missing FROM-clause entry for table "owners_houses",
在日志中没有从子句
加入这有效:
House.paginate(
:page=>1,
:include=>[:creator, :owner],
:per_page=>20,
:conditions=>"owners_houses.architect ILIKE E'%tom%' and houses.city ILIKE E'%new yo%'")
这是will_paginate中的错误吗?为什么会这样?
答案 0 :(得分:0)
检查development.log以查找为WORKING和NON WORKING语句生成的Sql查询