Forum: Ruby String issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A6af42e1a10fe69445480a6165e0187a?d=identicon&s=25 Prashant Katare (pkatare)
on 2009-05-07 11:13
Hello,

I am trying to display the time spent in performing an activity in HTML
format.

The code below does that. If the time is 0 it shouldn't show anything
else it should show the "time" followed by "hours" word.

"<td>
    #{start_time[:hrs] == 0 ? "" : start_time[:hrs] + hours}
</td>"

The way I am trying to do is giving problems.

 "TypeError Exception: String can't be coerced into Fixnum"
This is because of the "+ hours" in the code.

Any solution to get this done?
20228e1a65c9717555f80030a6e8779f?d=identicon&s=25 Rüdiger Brahns (Guest)
on 2009-05-07 11:31
(Received via mailing list)
Prashant Katare schrieb:
> </td>"
>
> The way I am trying to do is giving problems.
>
>  "TypeError Exception: String can't be coerced into Fixnum"
> This is because of the "+ hours" in the code.
>
> Any solution to get this done?

start_time[:hrs].to_s + hours
A6af42e1a10fe69445480a6165e0187a?d=identicon&s=25 Prashant Katare (pkatare)
on 2009-05-07 11:53
Thanks for your solution
This topic is locked and can not be replied to.