Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing a string array without quotes in Ruby on Rails

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?

like image 944
alahaitu Avatar asked Aug 24 '12 11:08

alahaitu


1 Answers

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('"', '')
like image 63
auralbee Avatar answered Sep 20 '22 04:09

auralbee