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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:52:19+00:00 2026-05-12T14:52:19+00:00

I believe this has been asked/answered before in a slightly different context, and I’ve

  • 0

I believe this has been asked/answered before in a slightly different context, and I’ve seen answers to some examples somewhat similar to this – but nothing seems to exactly fit.

I have an array of email addresses:

@emails = ["test@test.com", "test2@test2.com"]

I want to create a hash out of this array, but it must look like this:

input_data = {:id => "#{id}", :session => "#{session}", 
              :newPropValues => [{:key => "OWNER_EMAILS", :value => "test@test.com"} , 
                                 {:key => "OWNER_EMAILS", :value => "test2@test2.com"}]

I think the Array of Hash inside of the hash is throwing me off. But I’ve played around with inject, update, merge, collect, map and have had no luck generating this type of dynamic hash that needs to be created based on how many entries in the @emails Array.

Does anyone have any suggestions on how to pull this off?

  • 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-12T14:52:19+00:00Added an answer on May 12, 2026 at 2:52 pm

    So basically your question is like this:

    having this array:

    emails = ["test@test.com", "test2@test2.com", ....]
    

    You want an array of hashes like this:

    output = [{:key => "OWNER_EMAILS", :value => "test@test.com"},{:key => "OWNER_EMAILS", :value => "test2@test2.com"}, ...]
    

    One solution would be:

    emails.inject([]){|result,email| result << {:key => "OWNER_EMAILS", :value => email} }
    

    Update: of course we can do it this way:

    emails.map {|email| {:key => "OWNER_EMAILS", :value => email} }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe this questions has been asked in some or the other way but
I believe this has been asked before but no concrete answer has been determined.
I see that this question has been asked before but the context around the
I believe that this question has been asked in a few different forms, but
I believe this question has been asked before. I tried looking for it but
(Apologies if this has been asked before - I can't believe it hasn't, but
I apologize if this has been asked before, but I believe that for me,
I know that this has been asked many times before, but I believe my
While I'm perfectly willing to believe that this has been asked elsewhere, I haven't
I believe this question has been asked a lot of times, and I have

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.