Displaying 1 result from an estimated 1 matches for "index_two".
Did you mean:
index_io
2008 Jun 17
3
rindex not working with objects from db model
...scores = Testscore.find(:all, :conditions=> {...})
my_testscore = current_user.test_score
my_ts = Testscore.new(:score => my_testscore)
test_scores.push(ts)
sorted_ts = test_scores.sort {|x,y| x.score <=> y.score }
index_one = sorted_ts.index(my_ts)
# why doesn''t this work?
index_two = sorted_ts.rindex(my_ts)
It finds index_one correctly, but index_two always equals index_one,
even if there are more than one object with a score of my_testscore.
Please help! Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received t...