# String issue

**URL:** <https://www.ruby-forum.com/t/string-issue/167388>\
**Category:** Ruby\
**Created:** [May 7, 2009, 11:13am UTC](https://www.ruby-forum.com/t/string-issue/167388 "2009-05-07T11:13:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkatare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@pkatare](https://www.ruby-forum.com/u/pkatare)\
**Post date:** [May 7, 2009, 11:13am UTC](https://www.ruby-forum.com/t/string-issue/167388/1 "2009-05-07T11:13:22Z")

</div>

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.

"

  
#{start\_time[:hrs] == 0 ? “” : start\_time[:hrs] + hours} "

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?

---

<div class="post-metadata">

**Author:** ![pkatare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@pkatare](https://www.ruby-forum.com/u/pkatare)\
**Post date:** [May 7, 2009, 11:31am UTC](https://www.ruby-forum.com/t/string-issue/167388/2 "2009-05-07T11:31:03Z")

</div>

Prashant K. schrieb:

> "
> 
> 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

---

<div class="post-metadata">

**Author:** ![pkatare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@pkatare](https://www.ruby-forum.com/u/pkatare)\
**Post date:** [May 7, 2009, 11:53am UTC](https://www.ruby-forum.com/t/string-issue/167388/3 "2009-05-07T11:53:27Z")

</div>

Thanks for your solution
