Class: SolidusBraintree::ConfigurationsController

Inherits:
Spree::Admin::BaseController
  • Object
show all
Defined in:
lib/controllers/backend/solidus_braintree/configurations_controller.rb

Instance Method Summary collapse

Instance Method Details

#listObject



7
8
9
10
11
# File 'lib/controllers/backend/solidus_braintree/configurations_controller.rb', line 7

def list
  authorize! :list, SolidusBraintree::Configuration

  @configurations = ::Spree::Store.all.map { |s| s.braintree_configuration || s.create_braintree_configuration }
end

#updateObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/controllers/backend/solidus_braintree/configurations_controller.rb', line 13

def update
  authorize! :update, SolidusBraintree::Configuration

  params = configurations_params[:configuration_fields]
  results = SolidusBraintree::Configuration.update(params.keys, params.values)
  if results.all?(&:valid?)
    flash[:success] = t('update_success', scope: 'solidus_braintree.configurations')
  else
    flash[:error] = t('update_error', scope: 'solidus_braintree.configurations')
  end
  redirect_to action: :list
end