1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-20 21:59:38 +02:00
Maybe/app/controllers/accounts_controller.rb
Josh Pigford 3bf7b47040 New bank addition (mostly hashing out STI bits)
Messy and gross. Will get cleaned up in the next couple of commits.
2024-02-02 10:39:16 -06:00

40 lines
690 B
Ruby

class AccountsController < ApplicationController
before_action :authenticate_user!
def index
@accounts = current_family.accounts
end
def new
end
def new_bank
@account = DepositoryAccount.new
end
def show
end
def create
@account = account_type_class.new(account_params)
@account.family = current_family
if @account.save
redirect_to accounts_path
else
render :new
end
end
private
def account_params
params.require(:account).permit(:name, :balance, :type, :subtype)
end
def account_type_class
params[:type].constantize
rescue
Account # Default to Account if type is not provided or invalid
end
end