On Wed, Jan 5, 2011 at 5:28 AM, bourne <[email protected]> wrote:
> Given one model with a more complex sort in it.
> @products = Product.all
>
> If I now have the ID of a product that is in @products - what is the best
> way to find the previous/next element (keeping the model sort in mind, e.g.
> the previous / next with respect to the custom sort, not with respect to the
> database)? Is there a better way than stepping through using .each?

@products is just an Array; you should look through the doc to see
the methods available.  You might find Array#index and Array#at of
interest. :-)

HTH,
-- 
Hassan Schroeder ------------------------ [email protected]
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to