Reputation: 10885
Hi i come cross problem where i want to assign an array in to another array
like i have this value save in DB of a attribute of table like
["rogid", "soni"]
a_array = []
after retrieving from DB i want to assign as it
a_array = ["rogid", "soni"]
after assign it should look like this after i display
["rogid", "soni"]
but when i display a_array it is like this
["[\"rogid\", \"soni\"]"]
how i can achive it like same as ["rogid", "soni"]
Many many thanks for help
Upvotes: 0
Views: 119
Reputation: 1417
You could use a regex to parse the string: rogid an soni on rubular
Im getting some odd ruby behavior here so i cannot confirm this answer right now, but im pretty sure you can handle it:
my_pattern.match(my_string).to_a
will return you desired array.
Also dont forget pull "[\"rogid\", \"soni\"]"
from ["[\"rogid\", \"soni\"]"]
before using the regex.
Upvotes: 1