Class: Gera::CurrencyRateModeSnapshotsController

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

Instance Method Summary collapse

Instance Method Details

#activateObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 35

def activate
  snapshot.transaction do
    CurrencyRateModeSnapshot.status_active.update_all status: :deactive
    snapshot.update status: :active
  end
  CurrencyRatesWorker.perform_async if Rails.env.production?
  flash[:success] = 'Режимы активированы'
  redirect_to currency_rate_mode_snapshot_path snapshot
end

#createObject



52
53
54
55
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 52

def create
  flash[:success] = 'Создана новая матрица методов расчета'
  redirect_to edit_currency_rate_mode_snapshot_path(create_draft_snapshot)
end

#editObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 15

def edit
  if snapshot.status_draft?
    render :edit, locals: {
      snapshot: snapshot
    }
  else
    redirect_to currency_rate_mode_snapshot_path snapshot
  end
end

#indexObject



11
12
13
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 11

def index
  redirect_to edit_currency_rate_mode_snapshot_path Universe.currency_rate_modes_repository.snapshot
end

#showObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 25

def show
  if snapshot.status_draft?
    redirect_to edit_currency_rate_mode_snapshot_path snapshot
  else
    render :edit, locals: {
      snapshot: snapshot
    }
  end
end

#updateObject



45
46
47
48
49
50
# File 'app/controllers/gera/currency_rate_mode_snapshots_controller.rb', line 45

def update
  snapshot.update permitted_params
  respond_to do |format|
    format.json { respond_with_bip(snapshot) }
  end
end