diff options
author | HombreLaser <sebastian-440@live.com> | 2023-03-22 20:23:12 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-03-22 20:23:12 -0600 |
commit | 25fd0c4da93d664747eb5e6eca25413cead97452 (patch) | |
tree | e3c48e43bc1e64d7977b19e37f4851fdad9e7900 | |
parent | 6dda37a27500c3a2e48b22b3e4e0a021a45853d2 (diff) |
Añade dependent :destroy a la relación entre address y su join table
-rw-r--r-- | app/models/address.rb | 6 |
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 |