I have an ActiveRecord model object @gallery
which represents a row in the Galleries MYSQL table. Is there a way for me to ask @gallery
to give me the id to the next gallery object in the table?
The obvious way for me to do this is to :
@galleries = Gallery.find(:all)
index = @galleries.index(@gallery)
@nextgallery = @galleries[index+1]
but then I have to nilsafe this and I'm unnecessarily making another DB call to fetch all records. Any other way out?