Class: Backend::BankStatementItemsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/bank_statement_items_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

account_lettering_states_crit, accounts_range_crit, amount_range_crit, crit_params, journal_entries_states_crit, journal_letter_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name, #session_controller?

Instance Method Details

#createObject


13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/backend/bank_statement_items_controller.rb', line 13

def create
  @initiator_form = params[:bank_statement_item][:initiator_id]
  return head :bad_request unless @initiator_form && @bank_statement = BankStatement.find(params[:bank_statement_item][:bank_statement_id])
  safe_params = permitted_params
  @bank_statement_item = @bank_statement.items.new(safe_params)
  return head :bad_request unless @bank_statement_item.save!
  respond_to do |format|
    format.js { render }
  end
end

#destroyObject


24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/backend/bank_statement_items_controller.rb', line 24

def destroy
  @bank_statement_item = BankStatementItem.find(params[:id])

  id = @bank_statement_item.id
  return head :bad_request unless @bank_statement_item
  return head :failed unless @bank_statement_item.destroy
  respond_to do |format|
    format.js { render json: { id: id } }
  end
end

#newObject


3
4
5
6
7
8
9
10
11
# File 'app/controllers/backend/bank_statement_items_controller.rb', line 3

def new
  return head :bad_request unless @bank_statement = BankStatement.find(params[:bank_statement_id])
  @bank_statement_item = BankStatementItem.new(permitted_params)
  if request.xhr?
    render partial: 'bank_statement_item_row_form', locals: { item: @bank_statement_item, bank_statement: @bank_statement }
  else
    redirect_to_back
  end
end