Hi, thanks for taking the time to read my article. Visit aaronvb.com for more reads, and contact me below if you have questions.

AARON VAN BOKHOVEN

You can find me on GitHub, Twitter, Instagram, Flickr, or email at bokhoven@gmail.com

Ruby Array to Javascript Array

Written Aaron Van Bokhoven on Mar 10, 2010

Need to pass a Ruby Array to a Javascript Array? Here’s a little gem I found a while ago that I’m reusing in my current project.

>> a_ruby_array = ["one", "two", "three"]
=> ["one", "two", "three"]
>> "['#{a_ruby_array.join('\',\'')}']"
=> "['one','two','three']"