destructure guardian address field for appearance release

This commit is contained in:
bilal
2020-06-16 13:29:13 +02:00
parent a7b90c223b
commit 50d8ea158e
12 changed files with 108 additions and 10 deletions

View File

@@ -16,6 +16,18 @@ class AppearanceRelease < ApplicationRecord
has_one_attached :person_photo
composed_of :guardian_address,
class_name: 'Address',
mapping: [
%w[guardian_address_street1 street1],
%w[guardian_address_street2 street2],
%w[guardian_address_city city],
%w[guardian_address_state state],
%w[guardian_address_zip zip],
%w[guardian_address_country country]
]
# These validations apply to all releases
validates :person_email, email: true, allow_blank: true
validates :person_first_name, :person_last_name, presence: true
@@ -73,6 +85,19 @@ class AppearanceRelease < ApplicationRecord
searchable_on %i[person_first_name person_last_name person_address person_email person_phone]
def guardian_address
return self.guardian_address_old if self.guardian_address_old.present?
Address.new(
self.guardian_address_street1,
self.guardian_address_street2,
self.guardian_address_city,
self.guardian_address_state,
self.guardian_address_zip,
self.guardian_address_country
).to_s(format: :full)
end
# All releases must respond to the following messages
def name
person_name