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?
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 S. ------------------------ [email protected]
twitter: @hassan