From 25fd0c4da93d664747eb5e6eca25413cead97452 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Wed, 22 Mar 2023 20:23:12 -0600 Subject: Añade dependent :destroy a la relación entre address y su join table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/address.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') 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 -- cgit v1.2.3