In Rails, I have a Product model. Sometimes I need to get multiple products at the same time (but the list is completely dynamic, so it can’t be done on the Rails side).
So, let’s say for this call I need to get products 1, 3, 9, 24 in one call. Is this possible? If so, do I need a custom route for this and what do I put in my controller?
i.e. does something like this work? /products/1,3,9,24
I don’t think you should need to change the routes at all. You should just have to parse them in your controller/model.
If you then send a request to
http://localhost/products/1,3,9,24, @products should return 4 records.