Class: InstanceConfigurationController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InstanceConfigurationController
- Defined in:
- app/controllers/instance_configuration_controller.rb
Instance Method Summary collapse
Instance Method Details
permalink #index ⇒ Object
[View source]
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/instance_configuration_controller.rb', line 20 def index :show, Iqvoc.config settings = Iqvoc.config.defaults. each_with_object({}) do |(key, default_value), hsh| hsh[key] = serialize(Iqvoc.config[key], default_value) end @settings_by_namespace = settings.inject({}) do |memo, (key, value)| namespace, setting = key.split('.', 2) namespace = setting ? namespace : 'common' memo[namespace] ||= {} memo[namespace][key] = value memo end end |
permalink #update ⇒ Object
[View source]
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/instance_configuration_controller.rb', line 37 def update :update, Iqvoc.config # deserialize and save configuration settings errors = [] config_params.each do |key, value| unless Iqvoc.config.defaults.include?(key) errors << t('txt.controllers.instance_configuration.invalid_key', key: key) else default_value = Iqvoc.config.defaults[key] begin Iqvoc.config[key] = deserialize(value, default_value) rescue TypeError => exc Rails.logger.error(exc) Rails.logger.error(exc.backtrace.join("\n")) errors << t('txt.controllers.instance_configuration.invalid_value', key: key, error_message: exc.) end end end if errors.none? flash[:success] = t('txt.controllers.instance_configuration.update_success') else flash[:error] = t('txt.controllers.instance_configuration.update_error', error_messages: errors.join('; ')) end redirect_to instance_configuration_url end |