Ruby: logger.debug with an array

When you try logging something like:

logger.debug(“This won’t work: ” + @anarray)

you’ll get a syntax error:

     TypeError (no implicit conversion of Array into String):

Instead use .inspect

e.g. this will work:

logger.debug(“This will work: ” + @anarray.inspect)

See also:

http://stackoverflow.com/questions/5196240/logger-debug-this-is-an-array-rails

Leave a Reply

Your email address will not be published. Required fields are marked *