나는 모델에서 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
나는
@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