It looks like the object returned by tournament.date
is of type Time
, where as DateTime.parse
expects a string. The underlying implementation of the parse
method does a gsub!
on the argument passed. Hence the error.
You have two solutions :
If you always get a
Time
object fromtournament.date
then you can usetournament.date.to_datetime
(Although I don't think you actually need aDateTime
object. You can use theTime
object for thestrftime
)If you aren't guaranteed a
Time
object then pass the stringified object toparse
like thisDateTime.parse(tournament.date.to_s)
P.S : I do not know how this code worked for you on your local machine. Could be because of different ruby versions in the two setups. My answer is based on MRI 1.9.2.