質問編集履歴

1

訂正後コード

2021/07/01 12:01

投稿

IRIESS
IRIESS

スコア45

test CHANGED
File without changes
test CHANGED
@@ -67,3 +67,29 @@
67
67
 
68
68
 
69
69
  ```
70
+
71
+
72
+
73
+
74
+
75
+ ### 追記
76
+
77
+
78
+
79
+ ```ruby
80
+
81
+ def duplication_of_work_hours_for_same_user
82
+
83
+ result = Agreement.where('finish_time >= ? && ? >= start_time && user_id = ?', start_time, finish_time, user_id)
84
+
85
+ unless result.blank?
86
+
87
+ errors.add(:start_time, "勤務時間が他の勤務時間と重複しています。")
88
+
89
+ end
90
+
91
+ end
92
+
93
+
94
+
95
+ ```