MultiAccount : Deleting an "Account" : View -> Edit -> Delete : Errors Out (Either Current or Other)

When in the GUI and as the owner, trying to delete an Account (even when not switched to the current_account).. the delete action to https://localapp.pansift.com/accounts/11/members/16/edit results in:
ActiveRecord::RecordNotFound in AccountUsersController#edit
Couldn't find Account with 'id'=11 [WHERE "account_users"."user_id" = $1]
Extracted source (around line #40): def set_account @account = current_user.accounts.find(params[:account_id]) end
This happens whether
current_account
is the one being deleted or not. Originally I thought I was trying to delete the account but then realised it is trying to delete the account_user
only and erroring...It attempts to remove the
account_user
but does not remove the account. The above error can be fixed by editing the AccountsUsersController DELETE method to redirect to the accounts_path rather than the @account path which tried to invoke set_account
...From:
# DELETE /account_users/1 def destroy @account_user.destroy redirect_to @account, notice: t(".destroyed") end
To:
# DELETE /account_users/1 def destroy @account_user.destroy redirect_to accounts_path, notice: t(".destroyed") end
as the
set_account
method can not set the @account as current_user
does not now have the association listed?What am I missing? It still feels like it leaves spurious orphaned accounts lying around? Should there be a depenedent_destroy if no other account_users?
Notifications
You’re not receiving notifications from this thread.