0
ここでは、接続してwhere
句を実行しようとする非常に簡単な関係があります。これはRails 3ではうまくいきましたが、Rails 4ではこれ以上は機能しません。構文はすべて正しいものです。 listing.seller
またはseller.listings
のようなすべてのレコード関係は、すべて正常に動作します。あなたは、実際のテーブル名を使用する必要がWHERE句で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"."...
ありがとう!それがトリックでした。 –