Monday, June 11, 2012

Rails number_to_percentage always 0

This is a silly mistake that I often make.

# This always return a big fat zero
number_to_percentage(User.count/Signup.count)

# Remember to have divide by floats!
number_to_percentage(User.count.to_f/Signup.count.to_f)

No comments: