Skip to content

Commit 827126d

Browse files
committed
added first version of a new function to check adult status at a certain date.
1 parent 7a59268 commit 827126d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/controllers/members/participants_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def participant_limit_check?
176176
end
177177

178178
def participant_alcohol_check?
179-
@activity.is_alcoholic? && @member.underage?
179+
@activity.is_alcoholic? && @member.underage_at?(@activity.start)
180180
end
181181

182182
# [PATCH] /activities/:id/participants

app/models/member.rb

+5
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ def underage?
246246
!adult?
247247
end
248248

249+
def underage_at?(event_date)
250+
return birth_date.blank? ||
251+
((18.years.ago + (event_date - Date.today)) < birth_date)
252+
end
253+
249254
def master?
250255
educations.any? do |education|
251256
education.status == 'active' && Study.find(education.study_id).masters

0 commit comments

Comments
 (0)