Converting Float to a String in Ruby
ruby, ruby-on-rails
Solution
This is because you're using a Float in place where a String is expected like the following example:
"Value = " + 1.2 # => no implicit conversion of Float into String
To fix this you must explicitly convert the Float into a String
"Value = " + 1.2.to_s # => Value = 1.2
Problem
Sometimes when I try to print a Float in rails, I get an error like this: ``` TypeError at /delivery_requests/33/edit no implicit conversion of Float into String on the line: = this_is_a_float ``` I know I can just add `.to_s` to the float, but why is this not done by default?