From cc243b0667ea959a8588996bd8f15c7c1170b17c Mon Sep 17 00:00:00 2001 From: Icewater1337 Date: Mon, 30 Mar 2015 19:59:47 +0200 Subject: [PATCH] set default values for database fields, country salutation and correspondence_language --- app/models/pbs/person.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/pbs/person.rb b/app/models/pbs/person.rb index f4f14b2cf..860759460 100644 --- a/app/models/pbs/person.rb +++ b/app/models/pbs/person.rb @@ -72,6 +72,16 @@ module Pbs::Person timeliness: { type: :date, allow_blank: true } alias_method_chain :full_name, :title + + after_initialize :defaults, unless: :persisted? + # ":if => :new_record?" is equivalent in this context + + end + + def defaults + self.country = "Schweiz" + self.salutation = "lieber_pfadiname" + self.correspondence_language = "de" end def salutation_label