Ruby-on-rails – Printing a string array without quotes in Ruby on Rails

arraysrubyruby-on-railsstring

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?

Best Answer

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('"', '')