Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Fix Merchants controller (#704)

Zach Gollwitzer75cdddc6cae2
diff --git a/app/controllers/transactions/merchants_controller.rb b/app/controllers/transactions/merchants_controller.rb
index 2d0dd2ce..2025a6d0 100644
--- a/app/controllers/transactions/merchants_controller.rb
+++ b/app/controllers/transactions/merchants_controller.rb
@@ -10,22 +10,16 @@ class Transactions::MerchantsController < ApplicationController
end
def create
- if Current.family.transaction_merchants.create(merchant_params)
- redirect_to transaction_merchants_path, notice: t(".success")
- else
- render transaction_merchants_path, status: :unprocessable_entity, notice: t(".error")
- end
+ Current.family.transaction_merchants.create!(merchant_params)
+ redirect_to transaction_merchants_path, notice: t(".success")
end
def edit
end
def update
- if @merchant.update(merchant_params)
- redirect_to transaction_merchants_path, notice: t(".success")
- else
- render transaction_merchants_path, status: :unprocessable_entity, notice: t(".error")
- end
+ @merchant.update!(merchant_params)
+ redirect_to transaction_merchants_path, notice: t(".success")
end
def destroy
diff --git a/config/locales/views/transaction/en.yml b/config/locales/views/transaction/en.yml
index 2f4de9df..12e2e841 100644
--- a/config/locales/views/transaction/en.yml
+++ b/config/locales/views/transaction/en.yml
@@ -59,7 +59,6 @@ en:
edit_categories: Edit categories
merchants:
create:
- error: Error creating merchant
success: New merchant created successfully
destroy:
success: Merchant deleted successfully
@@ -84,7 +83,6 @@ en:
new:
title: New merchant
update:
- error: Error updating merchant
success: Merchant updated successfully
update:
success: Transaction updated successfully