Rails validate uniqueness of date ranges

前端 未结 5 1094
情深已故
情深已故 2021-02-05 23:33

I have an application that involves absence records for employees.

I need to ensure that the start and end dates for each record don\'t overlap.

So for example,

5条回答
  •  半阙折子戏
    2021-02-05 23:52

    There is a gem called validates_overlap which allows you to easily validate date range overlaps. You can also use scopes on the validation.

提交回复
热议问题