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

  • Home
  • SEARCH
  • 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 6159405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:07:38+00:00 2026-05-23T21:07:38+00:00

Fellas! I’m creating my first independent project in Rails 3. This is mostly for

  • 0

Fellas! I’m creating my first independent project in Rails 3. This is mostly for practice. I’ve run in a problem.

The site gonna be about tarot predictions. In a form I ask for the deck and spread formation. In the controller I grab this and put in some variables. Than I have to list it out on the view.

The problem is:
I have (for ex) 10 cards for 10 positions. I want to list one card description with one position description. In my solution I build an array for the position descriptions and put the cards in a for cycle. Than I shift out the positions from the array with every step of the for.
In code:

<%  for cardnum in @cardnums
@cp = @card_positions.shift
@card = Card.find_by_id(cardnum)
%>
Writing out the data
<% end %>

However I think there are far more nice and clever solutions.

Is that possible to do the for cycle on two variables? Or any other nice solution?

Yours,
Kael

  • 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-23T21:07:38+00:00Added an answer on May 23, 2026 at 9:07 pm

    I do not exactly understand what you are trying to do, but

    cycle on two variables

    If you mean to iterate on two arrays at once, Array#zip can be helpful. You can do:

     a = [1,2,3]         # use card_position array
     b = %w{a b c}       # use cards array
     c = a.zip(b)        #=> [[1, "a"], [2, "b"], [3, "c"]]
    
     # you can do
     c.each do |cp, card|
       # do something with card_position(cp) and card
     end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Howdy fellas, this one is gonna be a doozy: So for awhile I've been
This is my first post so please go easy on me fellas. I am
Fellas! I've run into the Expected foo.rb to define Foo problem. I can't figure
Good fellas, My client requested a site in Wordpress, for now I will call
Hello good fellas i'm sure everybody is cool.I'm about to start a tutorial about
I am a Python newbie. I have this small problem. I want to print
Hey fellas, I have this weird bug, and I have no clue how to
How I can deserialize this : [{'fields': {'active': 1, 'image': 'http://img.rasset.ie/0003db75-150.jpg', 'name': 'Bad Fellas',
Good morning fellas. This is me again, David Dimalanta. I'm here for a question.
My first time really getting into caching with .NET so wanted to run a

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.