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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:12:05+00:00 2026-06-06T13:12:05+00:00

I am creating an array of hashes and passing it into a controller via

  • 0

I am creating an array of hashes and passing it into a controller via json. Here is the data that I am sending and some server output right before it:

Started POST "/api/user.json" for 127.0.0.1 at Wed Jun 27 18:52:32 -0400 2012
  Processing by Api::UsersController#create as JSON
  Parameters: {"accept"=>"json", "content_type"=>"json", "users"=>"[{\"email\":\"kirsten_gronberg@yahoo.com\"},{\"email\":\"dtsheahan@msn.com\"},{\"email\":\"clayton19361@hotmail.com\"},{\"email\":\"kumar.alka92@yahoo.com\"},{\"email\":\"j.eromes.n.d.c@gmail.com\\r\"},{\"email\":\"0\"},{\"email\":\"christine@colormepink.com\"},{\"email\":\"janabouc@gmail.com\"},{\"email\":\"carin@inkfoundry.com\"},{\"email\":\"jon.neiditz@nelsonmullins.com\"}]"}

here is my controller code:

params[“users”].each { |user_params|
User.create!(user_params)
}

and here is the error:

Completed 500 Internal Server Error in 2ms

NoMethodError (undefined method `keys' for #<String:0x10662d660>):
  app/controllers/api/users_controller.rb:6:in `create'
  app/controllers/api/users_controller.rb:5:in `each'
  app/controllers/api/users_controller.rb:5:in `create'

Would anyone have any idea what might be happening wrong for me here?

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-06-06T13:12:06+00:00Added an answer on June 6, 2026 at 1:12 pm

    When you receive params[:users], you are in fact receiving a string and not a hash. This string just happens to be encoded in JSON (i.e. in a style carrying the likeness of a Ruby hash.) You must convert this string into your hash through a method such as hash = JSON.parse(params[:users]).

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

Sidebar

Related Questions

I'm creating an array that needs to hold some empty values like this: $my_array['message']
I'm having some trouble manipulating an array of DNA sequence data that is in
I'm creating an array of view controllers, adding them to a UINavigation Controller, and
Why is it that for user defined types when creating an array of objects
what i want to do is that i am creating php array dynamic .i
I'm creating an array of Thread::Queue elements. I'm doing that like this: for (my
I'm creating an array of BackgroundWorker that shares one event handler like this: BackgroundWorker[]
i have a foreach loop when looping through that I am creating a $data
I am creating an array for some monetary values. I created the array as
Im having some issues creating an array of objects in javascript Please see my

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.