Convert configuration parameters to Hash for passing to FoodsoftConfig

This is required for compatibility with Rails 5.0.
This commit is contained in:
Patrick Gansterer 2020-03-23 16:18:58 +01:00
parent 6486f56b0d
commit e606f606da

View file

@ -19,7 +19,7 @@ class Admin::ConfigsController < Admin::BaseController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
# TODO support nested configuration keys # TODO support nested configuration keys
params[:config].each do |key, val| params[:config].each do |key, val|
FoodsoftConfig[key] = val FoodsoftConfig[key] = convert_config_value val
end end
end end
flash[:notice] = I18n.t('admin.configs.update.notice') flash[:notice] = I18n.t('admin.configs.update.notice')
@ -54,4 +54,12 @@ class Admin::ConfigsController < Admin::BaseController
end end
end end
def convert_config_value(value)
if value.is_a? ActionController::Parameters
value.transform_values{ |v| convert_config_value(v) }.to_hash
else
value
end
end
end end