Let's say I have a Questions and Answer model, and I will answer all the answers to a specific question.
I can easily do each_with_index to and find out what the index or βplacementβ of the answer is (relative to other answers to this particular question).
But, say, I want to get a specific answer ... how can I guess what is the index of this answer in relation to all other answers related to a particular question.
Example Answer data:
ID text question_id 23 awesome 3 27 boooyah 3 38 snap 3
If I made Answer.find(27) , how can I determine that the record is the second element (if I order by ID ... although I could order any field).
object arrays ruby-on-rails order
Shpigford
source share