# How to output unescaped string to console?

**URL:** <https://www.ruby-forum.com/t/how-to-output-unescaped-string-to-console/160785>\
**Category:** Rails\
**Created:** [February 19, 2009, 5:17pm UTC](https://www.ruby-forum.com/t/how-to-output-unescaped-string-to-console/160785 "2009-02-19T17:17:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@bobm](https://www.ruby-forum.com/u/bobm)\
**Post date:** [February 19, 2009, 5:17pm UTC](https://www.ruby-forum.com/t/how-to-output-unescaped-string-to-console/160785/1 "2009-02-19T17:17:45Z")

</div>

Hi, whenever I display a string to the console (for debugging purpose) I  
get a bunch of \\ ‘’ “”""

1. It’s not human readable and really annoying when strings are very  
long
2. Sometime it prevents me to debug anything as I really don’t know if  
my quotes or backslashes are ok

I must mention that I’m displaying on the fly generated javascript, so  
the sense of my demand (could be applied to json generation to)

So, is there an helper method in Rails instead of just issuing p  
my\_script in my controller…

I thought about p unescape\_rjs(my\_script) but unescape\_rjs is a  
protected method of ActionController::Assertions::SelectorAssertions and  
such, not available in the controller.

Any idea ?

Note : I could certainly gsub gsub gsub but I’m not sure I would catch  
all the cases…

---

<div class="post-metadata">

**Author:** ![bobm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@bobm](https://www.ruby-forum.com/u/bobm)\
**Post date:** [February 19, 2009, 5:24pm UTC](https://www.ruby-forum.com/t/how-to-output-unescaped-string-to-console/160785/2 "2009-02-19T17:24:20Z")

</div>

BTW, a simple javascript formatter could even be better - I often  
struggle with RJS when I need to figure out the output render :update
