2016-08-04 1 views
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) 

が、私は思う:

enter image description here

+0

はい、2つの引数を '.where()' .. - > 'Date.current、listing_id:@ listing.id'に渡します。それは1でなければなりません: –

+0

あなたはそれを書くことができます: '( 'open_houses.start_date> =?AND listing_id =?'、Date.current、@ listing.id)' .. –

答えて

2

あなたはこのような何かを記述する必要がありますあなたはそれを期待していません。

関連する問題