I have the following request
model = (1,2,3,4) @posts = Post.where(category_id: id, product_model_id: model)
My above query is trying to take 1 from the model, how can I use the where in condition here
Edit-1
This part of the code works, but I do not think this is good code, right?
@posts = Post.where("category_id = ? and product_model_id in (#{model})", id)
Edit-2
If i use
@posts = Post.where ("category_id =? and product_model_id in (?)", id, model)
Throw error like
invalid input syntax for integer: "15,16" because my input is like this
select * from posts where category_id=5 and product_model_id in ('15,16')
How to fix it then ..
source share