<% if collection.prev_page %> <%= link_to('Previous', params.merge({:page => collection.prev_page}), {:class => 'previous'}) %> <% end %> <% if collection.next_page %> <%= link_to('Next', params.merge({:page => collection.next_page}), {:class => 'next'}) %> <% end %>