I\'m writing an app that uses Rails on the backend and javascript/backbone on the frontend. I\'m trying to bootstrap some rails models into my javascript. Specifically, I\'
The question is solved by my comment, just for the record:
Rails escapes strings that are printed using <%= 'string' %>
. By this, it is save to ouput user data.
So, if you don't want Rails to escape the output, you have to tell Rails explicitly by using raw('string')
.
In your code, that would be:
<%= raw(@courses.to_json) %>
If you intend to use raw(obj.to_json) you MUST ensure the following is set.
ActiveSupport.escape_html_entities_in_json = true