Q:

Parse ruby object in JavaScript (Rails)

in my view i have one object, and want to work with this onject from javascript
i try to 
  var js_obj  = jQuery.parseJSON('<%=raw @rails_obj.to_json %>');

it works. but if i have "'" symbols, new string symbols, ,,, in this object all fails.
Have somebody know good approach to do it? 

A:

JSON is valid Javascript right out of the box, so why not just do:
var js_obj = <%= @rails_obj.to_json %>;

A:

I find this to be the best way. Worked everytime
 <%= javascript_tag "var obj = #{@obj.to_json}" %>

