root.rb
root 'builders#result'
post 'builders/calc'
builders_controller.rb
class BuildersController < ApplicationController
def result
end
def calc
@hash = {0 => ["a", "b", "c"],1 => ["x", "y", "z"]}
@text = @hash.values.map{ |v| v.join(',') }.join("\n")
@result = @text
end
end
result.html.erb
<div id="total"></div>
calc.js.erb $('#total').html('<%= @result %>')
If I post @result like @result = @hash.values
I can see the result as [["a", "b", "c"], ["x", "y", "z"]]
but @result = @hash.values.map{ |v| v.join(',') }.join("\n")
not working?
Seems like problem with .join("\n")
but I need to save option to see each formated value from new line
Any fix? Thanks