Convert string into Array in rails
require 'json'
JSON.parse "[1,2,3,4,5]"
#=> [1, 2, 3, 4, 5]
JSON.parse "[[1,2],3,4]"
#=> [[1, 2], 3, 4]
Perhaps this?
s.tr('[]', '').split(',').map(&:to_i)
require 'json'
JSON.parse "[1,2,3,4,5]"
#=> [1, 2, 3, 4, 5]
JSON.parse "[[1,2],3,4]"
#=> [[1, 2], 3, 4]
Perhaps this?
s.tr('[]', '').split(',').map(&:to_i)