Get previous and next product id using a product id in rails app

Shopify Partner
28 0 2

Hi guys,

I am facing some difficulty finding the previous and next product id of a product in my rails app.

Let me explain it in detail.

What i am trying to do?

I am trying to create a admin product detail page similar to the shopify. i have a product id and I get the product information from product API. Now i would like to add the feature to navigate to previous product or next product from that detail page, so that customer don't need to go to product list and then again navigate to detail page. 

Check the screenshot to see what I mean .

Can someone suggest me the approach of doing it?