alex alex - 1 year ago 87
Ruby Question

find array element

I have an array

@words = Word.find_all_by_lesson_id(params[:id]) - @user.words

and want to find one element by word_id, something like

@current_word = @words[params[:id2].to_i]


Of course it's wrong, because the arrays index is not the same as
so how can I do it correct?


can you advice me on how to work with the model if I want to exclude some records from it?

Answer Source
@current_word = @words.detect{|w| == params[:id2]}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download