The personal finance app for everyone (by everyone)
Ruby
fix(goals): default goal currency so it survives a failed create (#2171)
Guillem Arias Fauste6a89efb9c9f7
diff --git a/app/controllers/goals_controller.rb b/app/controllers/goals_controller.rbindex 7406f8fe4a..1bb8f3c8aa 100644--- a/app/controllers/goals_controller.rb+++ b/app/controllers/goals_controller.rb@@ -61,7 +61,7 @@ class GoalsController < ApplicationControllerdef create@goal = Current.family.goals.new(goal_params)accounts = lookup_accounts(params.dig(:goal, :account_ids))- @goal.currency = accounts.first.currency if accounts.any? && @goal.currency.blank?+ @goal.currency = (accounts.first&.currency || Current.family.primary_currency_code) if @goal.currency.blank?Goal.transaction doaccounts.each { |a| @goal.goal_accounts.build(account: a) }