2018-03-06 13:44:29 +01:00
|
|
|
class Individual < ApplicationRecord
|
2016-08-30 11:18:43 +02:00
|
|
|
belongs_to :dossier
|
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
validates :dossier_id, uniqueness: true
|
2018-02-08 17:13:15 +01:00
|
|
|
validates :gender, presence: true, allow_nil: false, on: :update
|
|
|
|
validates :nom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
|
|
|
validates :prenom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
2019-08-01 09:34:26 +02:00
|
|
|
|
|
|
|
GENDER_MALE = 'M.'
|
|
|
|
GENDER_FEMALE = 'Mme'
|
|
|
|
|
|
|
|
def self.create_from_france_connect(fc_information)
|
2019-11-12 18:29:37 +01:00
|
|
|
create!(
|
2019-08-01 09:34:26 +02:00
|
|
|
nom: fc_information.family_name,
|
|
|
|
prenom: fc_information.given_name,
|
|
|
|
gender: fc_information.gender == 'female' ? GENDER_FEMALE : GENDER_MALE
|
|
|
|
)
|
|
|
|
end
|
2016-08-30 11:18:43 +02:00
|
|
|
end
|