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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:59:05+00:00 2026-06-19T00:59:05+00:00

I have defined my hash and arrays like this: POPULATION_SUMMARIES = { ‘ACO’ =>

  • 0

I have defined my hash and arrays like this:

POPULATION_SUMMARIES = {
    'ACO' => [   # year , member_count
        [2013, 523031],
        [2012, 492349],
        [2011, 432573]
    ]
}

So the table I want to insert into is PopulationSummary . And its row/fields are like this:

    ACO, 2013, 523031
    ACO, 2012, 492349
    ACO, 2011, 432573
Org_id, year, member_count

In DB, It’s actually the ID of those “ACO” or other stuff, they are basically foreign keys of another table.(ie. Organization table).

So I am trying to loop through this and read the structure and write it in the table.
I went as far as something like this:

  POPULATION_SUMMARIES.each do |k, v|
    org_id = Organization.find_by_name(k).id  # so for example ID of ACO
    v.each do |o| # now read elements of each array
      # HERE :(  QUESTION
    end
  end

So the part I am having trouble with is how to say Ok the first number you read from the array, insert it for the year field, the second number you read from the table: insert it for member_count field….

  • 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-06-19T00:59:06+00:00Added an answer on June 19, 2026 at 12:59 am

    This should get you close:

    POPULATION_SUMMARIES.each do |org_name, summaries|
      org = Organization.find_or_create_by_name(org_name)
    
      summaries.each do |year, member_count|
        PopulationSummary.create({
          :organization => org,
          :year         => year,
          :member_count => member_count
        })
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
What I have: Let's say I have a hash like this, with various values
I have defined an array like so : var myArray = {myNewArray: ['string1' ,
I have 7 arrays that are defined in the following manner: my @array1 =
Basically, I have an AJAX request like this: $.ajax({ url: http://192.168.0.100/, success: function(x) {
I need to index into a hash that I have defined in terms of
I have a class called GraphEdge which I would like to be uniquely defined
I have a hash map defined as class KeyType { int key; mutable bool
I have a perl hash of hashes like the following: $VAR1 = { 'ID_1'
I have a class in Model which has a hash defined. {:manager => 1,

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.