[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

String issue

Prashant Katare

5/7/2009 9:13:00 AM

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?
--
Posted via http://www.ruby-....

2 Answers

Rüdiger Brahns

5/7/2009 9:30:00 AM

0

Prashant Katare schrieb:
> 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?

start_time[:hrs].to_s + hours

Prashant Katare

5/7/2009 9:54:00 AM

0

Thanks for your solution
--
Posted via http://www.ruby-....