0
这是一个非常简单的关系,我试图连接并运行一个where
子句。这在Rails 3中运行良好,但不再适用于Rails 4.语法对我来说都是正确的。所有记录关系如listing.seller
或seller.listings
均按预期工作。PG :: UndefinedTable错误与Rails 4中的关联where子句
class Listing < ActiveRecord::Base
belongs_to :seller, class_name: "User"
end
然而
Listing.joins(:seller).where({ seller: { id: 1 } })
# Or
Listing.eager_load(:seller).where({ seller: { id: 1 } })
# Both result in the following error:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "seller"
LINE 1: ...s" ON "users"."id" = "listings"."seller_id" WHERE "seller"."...
谢谢!那就是诀窍。 –