mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 21:59:38 +02:00
40 lines
690 B
Ruby
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
|