0
これらの引数の両方を含むステートメントを作成しようとしていますが、「間違った数のバインド変数」エラーが発生し続けます。私は以下のコードを掲載しました。どんな助けもありがとうございます。Railsコントローラに間違った数のバインド変数エラーがあります
コントローラー:
@open_houses = OpenHouse.upcoming.where('open_houses.start_date >= ?', Date.current, listing_id: @listing.id).order(start_date: :asc)
がエラー:レールがwhere('open_houses.start_date >= ?', Date.current, listing_id: @listing.id)
を見たとき、それはwhere('open_houses.start_date >= ? AND listing_id = :listing_id', Date.current, listing_id: @listing.id)
想定しているため
OpenHouse.
upcoming.
where(listing_id: @listing.id).
where('open_houses.start_date >= ?', Date.current).
order(start_date: :asm)
が、私は思う:
はい、2つの引数を '.where()' .. - > 'Date.current、listing_id:@ listing.id'に渡します。それは1でなければなりません: –
あなたはそれを書くことができます: '( 'open_houses.start_date> =?AND listing_id =?'、Date.current、@ listing.id)' .. –