summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/address.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/address.rb b/app/models/address.rb
index 260407d..6d542ab 100644
--- a/app/models/address.rb
+++ b/app/models/address.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
# Address
-# number: string
+# number: integer
# street: string
# zip_code: string
# country: string
# city: string
class Address < ApplicationRecord
- has_many :user_account_addresses
+ has_many :user_account_addresses, dependent: :destroy
has_many :user_accounts, through: :user_account_addresses
validates :number, presence: true
@@ -19,7 +19,7 @@ class Address < ApplicationRecord
validates :city, presence: true
def valid_country
- return unless Country[country].nil?
+ return if ISO3166::Country.codes.include?(country)
errors.add(:country, 'Invalid country')
end