summaryrefslogtreecommitdiff
path: root/app/controllers/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/services')
-rw-r--r--app/controllers/services/create_address_service.rb3
-rw-r--r--app/controllers/services/update_address_service.rb1
2 files changed, 2 insertions, 2 deletions
diff --git a/app/controllers/services/create_address_service.rb b/app/controllers/services/create_address_service.rb
index 7b67af2..5ded4f7 100644
--- a/app/controllers/services/create_address_service.rb
+++ b/app/controllers/services/create_address_service.rb
@@ -7,8 +7,7 @@ module Services
def call
if already_existing_address.nil?
- @address = @user_account.address.new(@params)
- @address.save
+ @address = @user_account.addresses.create(@params)
else
add_address_to_user_addresses
@address = already_existing_address
diff --git a/app/controllers/services/update_address_service.rb b/app/controllers/services/update_address_service.rb
index 9f1ce54..26a596e 100644
--- a/app/controllers/services/update_address_service.rb
+++ b/app/controllers/services/update_address_service.rb
@@ -19,6 +19,7 @@ module Services
return :unprocessable_entity unless @address.update(@params)
else
add_address_to_user_addresses
+ @address.user_account_addresses.find_by(user_account_id: @user_account.id).destroy
@address.destroy if @address.user_accounts.count.zero?
@address = already_existing_address
end