Refactor contact type parsing to dynamic

This commit is contained in:
Martin Lensment 2014-07-31 10:35:32 +03:00
parent 8bff2fb34c
commit 292daa66e0
2 changed files with 13 additions and 19 deletions

View file

@ -31,18 +31,13 @@ class Domain < ActiveRecord::Base
end
def attach_contacts(contacts)
contacts[:tech].each do |x|
domain_contacts.create(
contact: Contact.find_by(code: x[:contact]),
contact_type: Contact::CONTACT_TYPE_TECH
)
end
contacts[:admin].each do |x|
domain_contacts.create(
contact: Contact.find_by(code: x[:contact]),
contact_type: Contact::CONTACT_TYPE_ADMIN
)
contacts.each do |k, v|
v.each do |x|
domain_contacts.create(
contact: Contact.find_by(code: x[:contact]),
contact_type: k
)
end
end
end