Class: Admin::FinancialTransactionTypesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/financial_transaction_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
# File 'app/controllers/admin/financial_transaction_types_controller.rb', line 15

def create
  @financial_transaction_type = FinancialTransactionType.new(params[:financial_transaction_type])
  if @financial_transaction_type.save
    redirect_to update_transaction_types_admin_finances_url, status: :see_other
  else
    render action: 'new', layout: false
  end
end

#destroyObject



34
35
36
37
38
39
40
41
# File 'app/controllers/admin/financial_transaction_types_controller.rb', line 34

def destroy
  @financial_transaction_type = FinancialTransactionType.find(params[:id])
  @financial_transaction_type.destroy!
  redirect_to update_transaction_types_admin_finances_url, status: :see_other
rescue StandardError => e
  flash.now[:alert] = e.message
  render template: 'shared/alert'
end

#editObject



10
11
12
13
# File 'app/controllers/admin/financial_transaction_types_controller.rb', line 10

def edit
  @financial_transaction_type = FinancialTransactionType.find(params[:id])
  render action: 'new', layout: false
end

#newObject



4
5
6
7
8
# File 'app/controllers/admin/financial_transaction_types_controller.rb', line 4

def new
  @financial_transaction_type = FinancialTransactionType.new(params[:financial_transaction_type])
  @financial_transaction_type.financial_transaction_class = FinancialTransactionClass.find_by_id(params[:financial_transaction_class]) if params[:financial_transaction_class]
  render layout: false
end

#updateObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/admin/financial_transaction_types_controller.rb', line 24

def update
  @financial_transaction_type = FinancialTransactionType.find(params[:id])

  if @financial_transaction_type.update(params[:financial_transaction_type])
    redirect_to update_transaction_types_admin_finances_url, status: :see_other
  else
    render action: 'new', layout: false
  end
end