Q:

SyntaxError: illegal character when posting array to data attribute of highcharts

I have a rails app that uses highcharts to display a line graph of 2 currencies. However when I run the app on my browser I keep getting the following error in firebug
SyntaxError: illegal character
 data: #&lt;Forex::ActiveRecord_Relation:0xc743144&gt;

I can't figure out what's wrong with my javascript code since it does not include the following after data attribute of highcharts
#&lt 

Here is my code:
<div id="forex">
<script type="text/javascript" charset="utf-8">
$(function() {
  new Highcharts.Chart({
  chart: {
    renderTo: "forex"
  },
  title: {
    text: "Forex"
  },
  xAxis: {
    type: "datetime"
  },
  yAxis: {
    title: {
      text: "Shillings"
    }
  },
  tooltip: {
    formatter: function() {
      return Highcharts.dateFormat("%B %e, %Y", this.x) + ': ' +
        "$" + Highcharts.numberFormat(this.y, 2);
    }
  },
  series: [
  <% { "Dollar" => Forex.dollar, "British Pound" => Forex.british_pound }.each do |name, value| %>
  {
    name: "<%= name %>",
    pointInterval: <%= 1.day * 1000 %>,
    pointStart: <%= 3.weeks.ago.to_i * 1000 %>,
    data: <%= value %>
  },
  <% end %>
  ]
});
});
</script>
</div>

I'm populating my data from a scope defined on forex.rb which is as follows
scope :dollar, -> { where(:us_dollar != 0) }
scope :british_pound, -> { where(:british_pound != 0 ) }

I've done according to Santosh's answer:
<% { "Dollar" => Forex.dollar, "British Pound" => Forex.british_pound }.each do |name, value| %>
  <p><%= name == 'Dollar' ? a=value.pluck(:us_dollar) : b=value.pluck(:british_pound) %></p>
<% end %>

But this prints out 2 empty arrays while I have 2 values in my table attributes
us_dollar: 88.27 and british_pound: 149.23

A:

Your scope syntax is wrong
Change the conditions to 
where(["us_dollar != ?", 0])

Change the data to
data: <%= name == 'Dollar' ? value.pluck(:us_dollar) : value.pluck(:british_pound) %>

