postgresql - Rails Activerecord/Postgres time format -


i working on rails project using postgres database. 1 of models, have time column, called (cleverly) time. when created model, set data type column 'time', (perhaps incorrect) understanding data type storing time only, no date.

t.time :time 

however, when submit data model, time correct prefixed incorrect date:

time: "2000-01-01 16:57:19" 

i want column store time (like '16:57:19'). 'time' correct data type use? or there other way should handle problem?

thank much.

the problem there no time-of-day class in ruby or rails. time classes dates or timestamps (i.e. date plus time of day).

inside database time (without timezone) column , behave inside database. however, once time gets ruby, activerecord add date component because there no plain time-of-day class available, happens use 2000-01-01 date.

everything fine inside database you'll have exercise little bit of caution ignore date component when you're outside database in rails.


Comments