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 7528803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:28:59+00:00 2026-05-30T04:28:59+00:00

In my view I have two instance variables (going to be more) that I

  • 0

In my view I have two instance variables (going to be more) that I want to display in one table. The first, @data, is an instance var of a model, someting like @data=RnFile.all.
The second is an array @result containing a value per data in @data calculated in the controller. Now in my view I want to display them next to each other, something like:

@data[0].atributes @result[0]
@data[1].atributes @result[1]
@data[2].atributes @result[2]
@data[3].atributes @result[3]
...

but I can’t figure out how to iterate over both the arrays (and propably more to come).
Any suggestions anyone? Thanks

  • 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-30T04:29:01+00:00Added an answer on May 30, 2026 at 4:29 am

    You can use Array#zip to do what you want:

    @data.zip(@results).each do |data, result|
      # use data and result as you need here
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two view controllers that allow changes to the Address Book. The first
I have a view that is joining two tables and ordering by the first
Inside my view.py, I have two functions, one that processes input from a form
I have two view controllers in a tabbar which can both edit data. Therefore,
I have two UIImageView objects inside my view (both 320x480 one above the other).
I have two views within one .xib (one view for landscape, another for portrait).
I have two views, one view takes the whole screen, the second view covers
I have two threads in an Android application, one is the view thread, and
I have two classes that each need an instance of each other to function.
We have two web applications and each one is creating it's own data context

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.