Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:27:32+00:00 2026-05-30T20:27:32+00:00

Im trying to for each loop true @participants collection like below: – (1..@participants.count).each do

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:27:34+00:00Added an answer on May 30, 2026 at 8:27 pm

    You don’t have to create a range, you can do the following, if participants is an array of participant objects:

    - @participants.each do |participant|
      - user = User.where(:id => participant.id).first
    

    It’s even better to setup a rails relation.

    class Participant
      belongs_to :user
    end
    

    This way you can simply do participant.user

    I can’t tell you how to setup those relations specifically because you did not give enough details. But this should get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the below code I'm trying to loop through each child node and append
I am trying to add preferences to user accounts. Each preference is true/false value
I'm trying reallocate more 256 bytes to buffer on each loop call. In this
I am trying to loop through each line in a file and find and
I am trying to change each parameter of this http://www.exampleofurl.com/search?q=4&e=25;i=8&b=2 through a loop, but
I am trying to loop though my users database to show each username in
I'm trying to assign a function for each element in a loop. I would
I am trying to print out the names of each person in the loop.
I am running a loop, and I am trying to create a variable each
I'm trying to write a loop to iterate over each anchor in an unordered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.