Is it possible to get the item(s) from previous or next pages in a
I have a 1-item-per-page Paginator, and I need to access the
attributes of the object in the previous and next pages.
Let me give my code to better illustrate the situation. In my
controller I have this:
@album = Album.find(:first,
:conditions => [‘slug = ?’, params[:albumslug]])
@photo = Photo.find(:first,
:conditions => [‘album_id = ? and slug = ?’,
@photo_pages, @photos =
:order_by => “order_rank asc”,
:per_page => 1,
:conditions => [“status=‘published’ and album_id = ?”,
@prevphoto = ??? # what to put here?
@nextphoto = ??? # what to put here?
And in my view photo.rhtml I have something like this:
<% if @prevphoto %>
<%= link_to image_tag(@prevphoto.src_uri,
:alt => h(@prevphoto.title),
:title => h(@prevphoto.title)),
photo_url(:albumslug => @prevphoto.album.slug,
:photoslug => @prevphoto.slug) %>
<% end %>
And similarly for @nextphoto.
Thanks in advance.