When creating “< previous|next >”-type navigation to browse through
records from a list of search results, what is the most efficient (best
practices-) way to determine what the previous and next records are for
a given record?
Should I store the search results array and the position (index) of the
current record in the session?
Or restore the results array each time (running the same search again)
and then determine the position of the current record inside that array
somehow (How can this be done in Ruby)? Sounds very inefficient to me.
Or even add two instance variables (@prev_record, @next_record) to the
record’s model that are populated (with the adjacent records) each time
a search is run, and then store the search results array in the session?