# Default rendered error file and hash to nice string how to

**URL:** <https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250>\
**Category:** Rails\
**Created:** [July 27, 2010, 1:09am UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250 "2010-07-27T01:09:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 27, 2010, 1:09am UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/1 "2010-07-27T01:09:55Z")

</div>

Hi,

When rails raises an exception which file (view?) gets rendered and  
outputs in the browser the backtrace, request, parameters, etc.

I’m asking that because I’d like to know if Rails provides an easy way  
to convert a hash to a readable string, eg:

“{:key =\> ‘value’}” instead of yukky #to\_s which gives “keyvalue”.

Thanks

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 27, 2010, 5:43pm UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/2 "2010-07-27T17:43:42Z")

</div>

On Mon, Jul 26, 2010 at 19:09, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’d like to know if Rails provides an easy way  
> to convert a hash to a readable string, eg:
> 
> “{:key =\> ‘value’}” instead of yukky #to\_s which gives “keyvalue”.

Maybe you can override to\_s?

-Dave

–  
Specialization is for insects. -RAH | Have Pun, Will Babble! -me  
Programming Blog: [http://codosaur.us](http://codosaur.us) | Work: [http://davearonson.com](http://davearonson.com)  
Leadership Blog: [http://dare2xl.com](http://dare2xl.com) | Play: [http://davearonson.net](http://davearonson.net)

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 27, 2010, 7:50pm UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/3 "2010-07-27T19:50:37Z")

</div>

Fernando P. wrote:

> Hi,
> 
> When rails raises an exception which file (view?) gets rendered and  
> outputs in the browser the backtrace, request, parameters, etc.
> 
> I’m asking that because I’d like to know if Rails provides an easy way  
> to convert a hash to a readable string, eg:
> 
> “{:key =\> ‘value’}” instead of yukky #to\_s which gives “keyvalue”.

Are you looking for something like p or inspect ?

> Thanks

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [August 15, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/4 "2010-08-15T18:16:20Z")

</div>

I think I’m experiencing an issue with Hash#inspect: if one of the  
values holds a file, it seems Ruby keeps it as a file, so I’ll let you  
guess what may happen if the file is a bit big when I just expect a  
little string to represent that file…

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 27, 2010, 10:46pm UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/5 "2010-07-27T22:46:14Z")

</div>

> Are you looking for something like p or inspect ?

Damn’ it! I completely forgot about Hash#inspect! Thanks Marnen 🙂

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [August 16, 2010, 6:01pm UTC](https://www.ruby-forum.com/t/default-rendered-error-file-and-hash-to-nice-string-how-to/192250/6 "2010-08-16T18:01:02Z")

</div>

Fernando P. wrote:

> I think I’m experiencing an issue with Hash#inspect: if one of the  
> values holds a file, it seems Ruby keeps it as a file, so I’ll let you  
> guess what may happen if the file is a bit big when I just expect a  
> little string to represent that file…

So check for File values. What’s the problem?

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
