I have an array that looks like this
ranking_array = ['NC', '40', '30/5', '30/4', '30/3', '30/2', '30/1', '30', '15/5', '15/4', '15/3', '15/2', '15/1', '15', '5/6', '4/6', '3/6', '2/6', '1/6', '0', '-2/6', '-4/6', '-15', '-30']
I have also a model user, my user has a ranking which is a value that is contained in ranking_array.
I have a model tournament with a max_ranking and a min_ranking which are both values contained in the ranking_array.
A user can only subscribe to a tournament if
tournament.min_ranking<=user.ranking <= tournament.max_ranking
I need a way to compare the value of rankings (ie ranking_array index because ranking_array is sorted from the lowest to highest ranking)
Thus, I need to write down a method comparing these values indexes:
if current_user.ranking_index > tournament.max_ranking_index
flash[:alert] = "Vous n'avez pas le classement requis pour vous inscrire dans ce tournoi"
elsif current_user.ranking_index < tournament.min_ranking_index
flash[:alert] = "Vous n'avez pas le classement requis pour vous inscrire dans ce tournoi"
How can I achieve that with each_with_index ?