Printing a string array without quotes in Ruby on Rails
12,380
I am not sure if I understand you right, but when outputting the array, you could do e.g.:
array = ["value1", "value2"]
array.to_s.gsub('"', '')
Author by
Admin
Updated on June 17, 2022Comments
-
Admin over 1 year
I need to print a string array inside a JavaScript wihout the string quotes.
I have an array containing string values and it is embedded to the page as <%= array %>. For the script, the array should printed in form of [[value1], [value2], [value3]] etc but when I output the array it adds quotes around the values so the script doesn't work.
How can I remove the quotes from the output?