0

I have an array with the elements [5,7,8,13]. These elements get dynamically generated based on a user’s action…they’re not hardcoded in.

I have a Product table. I would like to store the list of objects that have product id’s referenced in the array above.

@products = Product.where(id = those in the array)

I’m not sure how to do this. Any advice?

1 Answer 1

2

Just do

ids = [5,7,8,13]
@products = Product.where(id: ids)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.