ruby - Rails 4 - Updating an attribute based on time / date -
i on rails 4.
i have room model active? attribute. when creating room, users can set different times , dates want room active.
my goal: if user creates room dates mar 3 - mar 5, active? set true on mar 3 , false on mar 5. same goes if user sets times (ex. 10:00 - 5:00 pm)
what best way go this? having trouble finding documentation. appreciate if point me in right direction.
it's unclear how storing start , end date's, assuming have start_date , end_date, define active? method follows:
def active? date.current >= start_date && date.current < end_date end replace date datetime if needed
Comments
Post a Comment