Finding the position on an item in a collection

Here is my 2cents worth, but I would love to learn a better way.

the_collection = User.find(:all)

the_collection.map(&:id).index(23).

cheers ivor

This feels like it should be easy but i can’t work it out: if i have a collection of stories, ordered by (for example) date, then how do i find out the position of the story with id = (eg) 23 in the collection?

I guess this is a ruby question rather than a rails-specific question, but maybe there’s a rails way…

Posted via http://www.ruby-forum.com/.