What is the correct way to handle additional time information in Rails?

I am working on a Rails application that allows users to define tasks for which they are required due_date. due_datemay or may not include time.

The way we handle it now seems like a hack. due_datethe default is 12:00 AM, in which case we do not show the time. As far as I know, the object DateTimedoes not allow empty values ​​of time.

Should I split this information into two columns in the database? How do you guys handle this?

+3
source share
2 answers

, :

Ruby DateTime , , . 0, , . ( - 0 .)

, "1 2010 " DateTime 1 2010 . 00:00.

. - , , DateTime "show_time". - DateTime , DateTime .

Ruby, , 1. , , , - , . "( )".

PS

! , , .

+3

. , , ? , .. , , . , , .

, , .

+1

Source: https://habr.com/ru/post/1752540/


All Articles