How to deal with HTML entities in Rails to_json output?

后端 未结 2 806
终归单人心
终归单人心 2021-01-18 04:16

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\'

2条回答
  •  旧巷少年郎
    2021-01-18 04:52

    If you intend to use raw(obj.to_json) you MUST ensure the following is set.

    ActiveSupport.escape_html_entities_in_json = true 
    

提交回复
热议问题