私はモデルから1
は、どのように私はレール4は、同時に
編集こっちwhere in
条件を
model = (1,2,3,4)
@posts = Post.where(category_id: id, product_model_id: model)
私の上記のクエリがjusting取ってある次のクエリを使用することができています-1
このコードは機能しますが、これは正しいコードのように感じられません。
@posts = Post.where("category_id = ? and product_model_id in (#{model})", id)
編集-2
Iは
@posts = Post.whereを使用する場合( "CATEGORY_ID =と(?)でproduct_model_id"、ID、モデル)
invalid input syntax for integer: "15,16"
私の入力は次のようなものです:
select * from posts where category_id=5 and product_model_id in ('15,16')
..
コード注射を受け、あなたが持つことができない。モデル=(1,2,3,4 )あなたは配列を参照していますか? – bjhaid
@bjhaid私の編集 – overflow
を見てください。私の答えは – bjhaid