A
A
Alexander Petrov2015-11-25 22:50:27
Ruby on Rails
Alexander Petrov, 2015-11-25 22:50:27

How to display products by id array?

I have 3 tables. product, auto, use.
That is, goods, cars, and which goods belong to which cars.
We are making a request for AUDI A7.
use=Use.where(name: 'AUDI', model: 'A7')
returns an array of use and each element has a product ID. .
How to display products by ID array?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2015-11-25
@Mirkom63

Model.find([1,2,10])

T
TyzhSysAdmin, 2015-11-25
@POS_troi

No description of what links are used, no information at all.
if I understand the task correctly, then we read in the area "has_and_belongs_to_many"
rusrails.ru/active-record-associations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question