mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
20 lines
485 B
Ruby
20 lines
485 B
Ruby
class Address < ActiveRecord::Base
|
|
belongs_to :contact
|
|
belongs_to :country
|
|
|
|
class << self
|
|
def extract_attributes ah, type=:create
|
|
address_hash = {}
|
|
address_hash = ({
|
|
country_id: Country.find_by(iso: ah[:cc]).try(:id),
|
|
city: ah[:city],
|
|
street: ah[:street][0],
|
|
street2: ah[:street][1],
|
|
street3: ah[:street][2],
|
|
zip: ah[:pc]
|
|
}) if ah.is_a?(Hash)
|
|
|
|
address_hash.delete_if { |k, v| v.nil? }
|
|
end
|
|
end
|
|
end
|