Method to Prevent ' from turning into "

ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2

Solution

I ended up using: `data: <%= @product_count.to_json.html_safe %>`

I tried both `h` and `raw` and neither of those worked, however, `html_safe` did it.

Not sure why, but for future travelers I'm on rails version 3.2.7.

Problem

I have the following line: ``` data: <%= @product_count.to_json %> ``` which renders: ``` data: [[&quot;name1&quot;,20], [&quot;name2&quot;,9], [&quot;name3&quot;,18], [&quot;name4&quot;,32], [&quot;name5&quot;,28], [&quot;name6&quot;,17], [&quot;name7&quot;,11]] ``` in the view. How do I change this so I get the actual quotes instead of the HTML. The data comes from this line: ``` period_registration_product.each do |key, value| @product_count << [Product.find_by_id(key).name, value] end ``` Update: I tried: `data: <%= JSON.parse(@product_count.to_json) %>` and it failed.

Original source