1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(feat) hide child birthday > 18 years ago

This commit is contained in:
Du Peng 2023-07-12 08:44:02 +02:00
parent 67f5e68fd7
commit 03d71d7a84
3 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,7 @@ class API::ChildrenController < API::APIController
authorize Child
user_id = current_user.id
user_id = params[:user_id] if current_user.privileged? && params[:user_id]
@children = Child.where(user_id: user_id).includes(:supporting_document_files).order(:created_at)
@children = Child.where(user_id: user_id).where('birthday >= ?', 18.years.ago).includes(:supporting_document_files).order(:created_at)
end
def show

View File

@ -11,7 +11,7 @@ class Child < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
# validates :email, presence: true, format: { with: Devise.email_regexp }
# validate :validate_age
validate :validate_age
# birthday should less than 18 years ago
def validate_age

View File

@ -18,7 +18,7 @@ json.array!(@members) do |member|
end
end
json.validated_at member.validated_at
json.children member.children.order(:created_at) do |child|
json.children member.children.where('birthday >= ?', 18.years.ago).order(:created_at) do |child|
json.extract! child, :id, :first_name, :last_name, :email, :birthday, :phone, :user_id, :validated_at
json.supporting_document_files_attributes child.supporting_document_files do |f|
json.id f.id