I recommend using to_f.round
instead of to_i
any day of the week.
Even stronger evidence:
I think a lot of Rubyists were introduced to to_i
from DHH’s slug hack involving redefining Post#to_param
("15-hello-world".to_i #=> 15
), but I just don’t see many other uses for to_i
.