Class: Gera::PaymentSystemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/gera/payment_systems_controller.rb

Constant Summary collapse

EDIT_COLUMNS =
%i[
  name icon_url currency
  income_enabled outcome_enabled
].freeze
SHOW_COLUMNS =
%i[
  id icon_url name currency
  income_enabled outcome_enabled
  actions
].freeze

Instance Method Summary collapse

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
# File 'app/controllers/gera/payment_systems_controller.rb', line 40

def create
  PaymentSystem.create! permitter_params
rescue ActiveRecord::RecordInvalid => e
  render :new, locals: {
    payment_system: e.record,
    columns: EDIT_COLUMNS
  }
end

#editObject



49
50
51
52
53
54
# File 'app/controllers/gera/payment_systems_controller.rb', line 49

def edit
  render locals: {
    payment_system: PaymentSystem.find(params[:id]),
    columns: EDIT_COLUMNS
  }
end

#indexObject



19
20
21
22
23
24
# File 'app/controllers/gera/payment_systems_controller.rb', line 19

def index
  render locals: {
    payment_systems: PaymentSystem.order(:id),
    columns: SHOW_COLUMNS
  }
end

#newObject



33
34
35
36
37
38
# File 'app/controllers/gera/payment_systems_controller.rb', line 33

def new
  render locals: {
    payment_system: PaymentSystem.new,
    columns: EDIT_COLUMNS
  }
end

#showObject



26
27
28
29
30
31
# File 'app/controllers/gera/payment_systems_controller.rb', line 26

def show
  render locals: {
    payment_system: PaymentSystem.find(params[:id]),
    columns: SHOW_COLUMNS
  }
end

#updateObject



56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/gera/payment_systems_controller.rb', line 56

def update
  respond_to do |format|
    if payment_system.update_attributes permitter_params
      format.html { redirect_to(payment_systems_path, notice: 'Status was successfully updated.') }
      format.json { respond_with_bip(payment_system) }
    else
      format.html { render action: 'edit', locals: { payment_system: payment_system, columns: EDIT_COLUMNS } }
      format.json { respond_with_bip(payment_system) }
    end
  end
end