#10 ✓resolved
Aditya Babbar

Error "can't convert Fixnum into String" when Math.log() is called by number_to_human_size() method of Rails

Reported by Aditya Babbar | December 7th, 2009 @ 05:36 PM

Raised by Josh on the mailing list.

When number_to_human_size() method of ActionView::Helpers::NumberHelper is invoked in a Rails application running on WebROaR, the following error is seen.

ActionView::TemplateError (can't convert Fixnum into String) on line 
#148 of app/views/server/show.html.erb: 
145:         </tr> 
146:         <tr id="<%=Server.disk_color(@server.disk_size, 
@server.disk_used, "used")%>"> 
147:           <td>Used Diskspace</td> 
148:           <td><%=number_to_human_size(@server.disk_used)%></td> 
149:         </tr> 
150:         <tr id="data" class="even"> 
151:           <td>Total Diskspace</td> 
 app/views/server/show.html.erb:148 
    webroar (0.2.4) src/ruby_lib/profiler/webroar_profiling.rb:65:in 
`render' 
    app/controllers/server_controller.rb:46:in `show' 
    webroar (0.2.4) src/ruby_lib/profiler/webroar_profiling.rb:62:in 
`perform_action' 
    webroar (0.2.4) src/ruby_lib/ruby_interface/./rack/adapter/ 
rails.rb:73:in `call' 
    webroar (0.2.4) src/ruby_lib/ruby_interface/deflater.rb:16:in 
`call' 
    webroar (0.2.4) src/ruby_lib/ruby_interface/request_handler.rb: 
37:in `process'

"can't convert Fixnum into String" -- This error is being thrown by Math.log() called by number_to_human_size().

Comments and changes to this ticket

  • Josh Rendek

    Josh Rendek December 10th, 2009 @ 12:21 AM

    Aditya,

    I was hoping to take a stab at fixing this (tried before mailing the list) but I wasn't sure where to even start looking -- I poked around in webroar_profiling but wasn't able to come up with anything substantial that fixed the bug. Do you have any pointers so I can help with this?

    Josh

  • Aditya Babbar

    Aditya Babbar December 10th, 2009 @ 08:05 PM

    • State changed from “open” to “resolved”

    Josh,
    We have fixed this issue and pushed the changes to Github repository. Could you please pull the latest code and try out your application on it?

    We had defined one method called log using rb_define_singleton_method() and it was conflicting with the built-in method with the same name (log) called by Math.log invoked by number_to_human_size. We have renamed our method to log_message to prevent this collision.

    Thanks for reporting this issue and offering to look in to it!

    Aditya

  • Josh Rendek

    Josh Rendek December 10th, 2009 @ 08:16 PM

    Awesome! Worked perfectly now when I cloned from the git repo. Can't wait to start using this in production :).

    Regards,
    Josh

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<strong>Source Code Location</strong>
Repository is at <a href="http://github.com/webroar/webroar" target="_blank">http://github.com/webroar/webroar</a>
<p>
Check out the development master:
git clone git://github.com/webroar/webroar.git

<p>
<strong>Creating a bug report</strong>

When creating a bug report, be sure to include as much relevant information as possible.
<p>
Security vulnerabilities should be reported via an email to security@webroar.in, do not use lighthouse for reporting security vulnerabilities. All content in lighthouse is publicly available as soon as it is posted.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages