I have an array of hashes. Each entry is as follows:
- !map:Hashie::Mash
name: Connor H Peters
id: "506253404"
I am trying to create a second array containing only id values.
["506253404"]
This is how i do it
second_array = first_array.map { |hash| hash[:id] }
But I get this error
TypeError in PagesController
can't convert Symbol into Integer
If i try
second_array = first_array.map { |hash| hash["id"] }
I get
TypeError in PagesController
can't convert String into Integer
What am I doing wrong? Thanks for reading.
source
share