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]
where params[:id2]
is words.id
Of course it's wrong, because the arrays index is not the same as words.id
, so how can I do it correct?
OR
can you advice me on how to work with the model if I want to exclude some records from it?
@current_word = @words.detect{|w| w.id == params[:id2]}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.