I am trying to add pagination after a item from a paginated list is linked to. I can't seem to find a way to do this or find the answer. I am trying to display a list of images on a page, what I am trying to do is, when an image is clicked the user would go to that individual image page and then on the page there would be "Next" link to the next image in the list.
So, say I have a list of images in this order [1, 5, 3, 6, 4, 7, 8, 2, 9, 10 ]
display 5 per page. The user clicks image with id: 5 (position 1 in the list) and gets taken to '/images/5'. How do I add a link to the next image in this list (id: 3) and so on from there?
In the images controller
def index
@list = Images.first(10).shuffle
@images = Kaminari.paginate_array(@list).page(params[:page]).per(5)
end
What would I need in the corresponding views as well?