Default rendered error file and hash to nice string how to

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

Maybe you can override to_s?

-Dave

Fernando Perez 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,

Are you looking for something like p or inspect ?

Damn' it! I completely forgot about Hash#inspect! Thanks Marnen :slight_smile:

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...

Fernando Perez 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,