mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Find account first and build transaction through association (#487)
* Find account first and build transaction through association * Fix flaky test
This commit is contained in:
@@ -17,12 +17,9 @@ class TransactionsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@transaction = Transaction.new(transaction_params)
|
||||
account = Current.family.accounts.find(params[:transaction][:account_id])
|
||||
|
||||
raise ActiveRecord::RecordNotFound, "Account not found or not accessible" if account.nil?
|
||||
|
||||
@transaction.account = account
|
||||
@transaction = account.transactions.build(transaction_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @transaction.save
|
||||
|
||||
Reference in New Issue
Block a user