My goal is to transfer a 2D array from JavaScript to something that Ruby can interpret. All elements in the array are strings.
I have been using gon-sinatra, but it doesn't fulfill all my requirements. I tried storing the string I want to pass in 'gon.text' like this:
@temp = gon.text
array.push(@temp)
Unfortunately, this approach doesn't work because 'gon.text' appears as a nil object type instead of a string. When I try converting it using gon.text.to_s
, it returns an empty string. As a result, when I attempt to display it, nothing shows up. For example,
alert("<%= @temp %>") // displays an empty string
.
I am unsure about the best course of action at this point. Would it be more effective to store the array in JSON format and then parse it in Ruby?