title: Handling JSON in JS/ERB template in Rails 3
body: <p>I have no trouble making typical AJAX calls to and from Rails(3) with JSON objects and jQuery-rails (jQuery library plus a special rails.js file).</p>
  
  <p>In one controller, though, I want to RETURN some JSON in an erb template (create.js.erb) after an AJAX call.</p>
  
  <p>I've tried every combination of things in the controller (@object.to_json, '[{"content":"hello world"}]', etc.) and in the template itself (JSON.parse(), single quotes, double quotes, etc.), but the object keeps on rendering like this:</p>
  
  <pre><code>'[{&amp;quot;groups&amp;quot;:{},&amp;quot;created_at&amp;quot;:&amp;quot;2010-09-21T03:49:34Z&amp;quot; ...
  </code></pre>
  
  <p>and as a result, my jQuery code cannot parse it and I get errors. </p>
  
  <p>How do I need to prep my object in the controller, and what erb syntax do I need in the view for it to render as a valid JSON object?</p>
  
  <p>Thanks so much!</p>