The personal finance app for everyone
Add error handling for AccountsController#create (#957)
Tony Vincent3ffb6cb62be1
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rbindex 4633d8e9..8544b611 100644--- a/app/controllers/accounts_controller.rb+++ b/app/controllers/accounts_controller.rb@@ -3,7 +3,6 @@ class AccountsController < ApplicationControllerinclude Filterablebefore_action :set_account, only: %i[ edit show destroy sync update ]- after_action :sync_account, only: :createdef index@institutions = Current.family.institutions@@ -52,8 +51,10 @@ class AccountsController < ApplicationControllerattributes: account_params.except(:start_date, :start_balance),start_date: account_params[:start_date],start_balance: account_params[:start_balance]-+ @account.sync_laterredirect_back_or_to account_path(@account), notice: t(".success")+ rescue ActiveRecord::RecordInvalid => e+ redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentenceenddef destroy@@ -94,8 +95,4 @@ class AccountsController < ApplicationControllerdef account_paramsparams.require(:account).permit(:name, :accountable_type, :balance, :start_date, :start_balance, :currency, :subtype, :is_active, :institution_id)end-- def sync_account- @account.sync_later- endenddiff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erbindex 878cafc0..1e42a5d6 100644--- a/app/views/accounts/new.html.erb+++ b/app/views/accounts/new.html.erb@@ -86,7 +86,7 @@<%= label_tag :add_start_values, t(".optional_start_balance_message"), class: "pl-1 text-sm text-gray-500" %><div class="hidden peer-checked:flex items-center gap-2 mt-3 mb-6">- <div class="w-1/2"><%= f.date_field :start_date, label: t(".start_date"), max: Date.current %></div>+ <div class="w-1/2"><%= f.date_field :start_date, label: t(".start_date"), max: Date.yesterday %></div><div class="w-1/2"><%= f.number_field :start_balance, label: t(".start_balance") %></div></div></div>