post icon

RubyProf error “can’t convert Fixnum into String”

I recently maxxxxed out my memory limit on my regular dreamhost account at work causing 500 errors all over the place. This is now forcing me to start learning how to cache, and trace my apps for memory and performance. I also switched to PS with 300mb burstable to around 700mb. That should help out for now. Anyway, back to finding out which requests are drinking redbull… I installed the ruby-prof gem to find out. I ran a request with the param key added to the end of the url and wham! Errors? WTF? I copied the code right out of “Advanced Rails Recipes” correctly, and checked it 10 times? So what’s the error? “can’t convert Fixnum into String”? Well it seems that the printer class is trying to convert a number to a string:

response.body << printer.print("", 0)

Just change that to this and that:

response.body << printer.print("", '0')

Then it worked out fine! Hope that helps someone out cause I spent about 2 hours searching for the problem.

1 Comment

Leave a comment
  1. Mugur
    26. Sep, 2011 at 5:23 pm #

    Worked for me. Thanks for sharing.