Parse ruby object in JavaScript (Rails)
JSON is valid Javascript right out of the box, so why not just do:
var js_obj = <%= @rails_obj.to_json %>;
I find this to be the best way. Worked everytime
<%= javascript_tag "var obj = #{@obj.to_json}" %>