Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

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

#10

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

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

State: resolved
Milestone: none
Assigned to: Aditya Babbar Aditya Babbar

Activity

  1. Josh Rendek
    Josh Rendek

    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

    December 10th, 2009 @ 12:21 AM

  2. Aditya Babbar
    Aditya Babbar
    • 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

    December 10th, 2009 @ 08:05 PM

  3. Josh Rendek
    Josh Rendek

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

    Regards,
    Josh

    December 10th, 2009 @ 08:16 PM

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.