I'm new to RoR and web app development, Im using Rails 3.2.3 and I want to use a ruby array in Highcharts and I'm using Haml in my view files.
I have an array defined in the controller like so:
...
def show
...
@close_array = DailyQuote.where(company_id: @company.id).map(&:closing_price)
end
and I've declared it in my Haml view file.
%body
- close_array_j = "#{@close_array.inspect}"
=javascript_include_tag :build_chart
#container{:style => "min-width: 300px; height: 300px; margin: 0 auto"}
Now I want to use this array, close_array_j, in a Highcharts chart which I've written the code for in a separate file called build_chart.js:
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
},
...
series: [{
name: 'Closing Price',
data: $('#close_array_j')
}]
...
The highcharts chart is being rendered with no data. By the way, I dont know ruby or haml or js very well as you can probably tell...