Class: Admin::ConfigsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/generators/open_loam/install/templates/admin/configs_controller.rb

Overview

Per-tenant settings (OpenLoam::Configs). Structural, not per-record, so it is gated on the manager role rather than an entity policy — settings are privileged. Everything routes through OpenLoam::Configs, never OpenLoam::Config directly, so the cross-level resolution stays in vetted gem code.

Constant Summary

Constants included from Pagination

Pagination::PER_PAGE

Instance Method Summary collapse

Methods inherited from BaseController

skip_authorization!

Methods included from Pagination

#paginate

Instance Method Details

#edit ⇒ Object



18
19
20
21
22
# File 'lib/generators/open_loam/install/templates/admin/configs_controller.rb', line 18

def edit
  @key = params[:key]
  @value = OpenLoam::Configs.get(@key)
  @overridden = OpenLoam::Configs.overridden?(@key)
end

#index ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/generators/open_loam/install/templates/admin/configs_controller.rb', line 9

def index
  # Feature flags share the open_loam_configs store but have their own screen
  # (/admin/features), so hide their reserved-prefix keys from Settings.
  keys = OpenLoam::Configs.defined_keys.reject { |key| key.start_with?(OpenLoam::Features::PREFIX) }
  @settings = keys.map do |key|
    { key: key, value: OpenLoam::Configs.get(key), overridden: OpenLoam::Configs.overridden?(key) }
  end
end

#reset ⇒ Object



29
30
31
32
# File 'lib/generators/open_loam/install/templates/admin/configs_controller.rb', line 29

def reset
  OpenLoam::Configs.reset(params[:key])
  redirect_to admin_configs_path, notice: "#{params[:key]} reset to the default."
end

#update ⇒ Object



24
25
26
27
# File 'lib/generators/open_loam/install/templates/admin/configs_controller.rb', line 24

def update
  OpenLoam::Configs.set(params[:key], coerce(params[:value]))
  redirect_to admin_configs_path, notice: "#{params[:key]} set for this tenant."
end