If
@prescribed_wod_count = @user.workouts.rx_workouts.count
returns 4
and
@user_workout_count = @user.workouts.count
returns 26
how come
<%= number_to_percentage(@prescribed_wod_count / @user_workout_count) %>
returns 0.000%
and not 15% ?
It does integer division, before you call number_to_percentage.
You want
<%= number_to_percentage(@prescribed_wod_count.to_f / @user_workout_count) %>
to force it to do floating-point
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With