Module: AgreementsHelper
- Defined in:
- app/helpers/agreements_helper.rb
Overview
View helper: agreements.
Form-setup helpers for Agreement records and their nested
AgreementParticipant / ContactPoint associations.
Instance Method Summary collapse
-
#setup_agreement(agreement) ⇒ Agreement
Builds a default agreement participant on the agreement when none exist, so the form always renders at least one nested participant field.
-
#setup_agreement_participant(agreement_participant) ⇒ AgreementParticipant
Builds a default party (Contact) and EMAIL/PHONE contact points on the participant, so the form renders the nested fields it needs.
Instance Method Details
#setup_agreement(agreement) ⇒ Agreement
Builds a default agreement participant on the agreement when none exist,
so the form always renders at least one nested participant field.
14 15 16 17 18 |
# File 'app/helpers/agreements_helper.rb', line 14 def setup_agreement(agreement) agreement.tap do |a| a.agreement_participants.build if sc.agreement_participants.blank? end end |
#setup_agreement_participant(agreement_participant) ⇒ AgreementParticipant
Builds a default party (Contact) and EMAIL/PHONE contact points on the
participant, so the form renders the nested fields it needs.
25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/agreements_helper.rb', line 25 def setup_agreement_participant(agreement_participant) agreement_participant.tap do |ap| ap.party ||= Contact.new if ap.party.contact_points.empty? ap.party.contact_points.build(category: ContactPoint::EMAIL) ap.party.contact_points.build(category: ContactPoint::PHONE) end end end |