Im trying to for each loop true @participants collection like below:
- (1..@participants.count).each do |participant|
- @user = User.where(:id => 1).first
# @user = User.where(:id => particpant.id).first ==> throws error: ...
# (undefined method `id' for 1:Fixnum):
#participants
#block
#image
= show_avatar(@user.id)
#name
= @user.username
Confused on how to get the participant.id value for each looped object, cannot figure out how to after searched for a solution. Should I use a render collection instead or is there a way to get the participant.id for each looped participant? thx
You don’t have to create a range, you can do the following, if participants is an array of participant objects:
It’s even better to setup a rails relation.
This way you can simply do
participant.userI can’t tell you how to setup those relations specifically because you did not give enough details. But this should get you started.