diff --git a/app/models/contact.rb b/app/models/contact.rb index 11a926185..69c110945 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -17,6 +17,8 @@ class Contact < ActiveRecord::Base accepts_nested_attributes_for :legal_documents + before_save :catch_legal_doc_id + validates :name, :phone, :email, :ident, :ident_type, :street, :city, :zip, :country_code, :registrar, presence: true @@ -515,4 +517,13 @@ class Contact < ActiveRecord::Base log end + def catch_legal_doc_id + + if !legal_document_id && doc = self.legal_documents.last.new_record? + + legal_document_id = doc.id + + end +end + end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 13f0379b5..54806b88d 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -38,9 +38,7 @@ class Epp::Contact < Contact legal_frame = f.css('legalDocument').first if legal_frame.present? - doc = legal_document_attrs(legal_frame) - self.legal_document_id = doc.id if doc.id - at[:legal_documents_attributes] = doc + at[:legal_documents_attributes] = legal_document_attrs(legal_frame) end at.merge!(ident_attrs(f.css('ident').first)) if new_record at