I'm trying to add hours and minutes that are stored in the database like this:
+----+---------+-------+
| id | user_id | time |
+----+---------+-------+
| 1 | 4 | 03:15 |
| 2 | 4 | 02:22 |
+----+---------+-------+
The time
field is a string
. How can I add the hours and minutes expressed by the strings like 05:37
?
I tried this
current_user.table.pluck(:time).sum(&:to_f)
but the output is only 5
.