I have an array of 'questions' ordered according to their number of votes, and want to show the question immediately before and immediately following the currently-selected question.
Let's say the currently-selected question is stored in the variable @question, and I'm showing a list of other questions associated with the same user. This code orders that list according to number of votes:
questions = Question.find(:all, :conditions => {:user => @question.user}).sort { |q1,q2| q2.votes.length <=> q1.votes.length}
Now how do I pick out just the question before and the question after @question in that list?