How to make will_paginate loop back to first on last entry?
If on the l开发者_运维知识库ast item of a collection, I'd like a "next" link that displays the first item again.
Not too sure about Ruby, but in php you would have a count of your rows. You could then make some kind of if statement to change the next link to the beginning of your results..
$base_url = 'http://google.com/paging?p=';
$count = 100;
$per_page = 10;
$page = $_GET['p'];
if($page > $count/$per_page){
$prev_link = $page - $per_page;
$next_link = $base_url;
}
Let me know if that helps.
精彩评论