Working with Rails 3.0, if one wanted to render some partial through javascript (in an AJAX call for example), one would escape the content like so
$('#some_id').html('<%= escape_javascript render(@post) %>');
and it would work, because escape_javascript escaped line breaks, quotes, and similar.
In Rails 3.1, the same method is escaping everything (including < for example), making it impossible for me to render content. Has this changed in 3.1? How do you do this?
Thanks in advance!
You’re probably on Rails 3.1.0.rc2 which was just released. There is a bug in
escape_javascriptthat was fixed right after the release (https://github.com/rails/rails/issues/1553) but is not in a published release yet.In the mean time, you can either revert to 3.1.0.rc1, or you can add an initializer to your project with the following:
UPDATE:
Rails 3.1.0.rc3 was released today which fixes this issue.